Is there any interest using more than 1 worker when you only have a singe core?

Viewed 207

I'm currently setting up a Gunicorn application on a single core machine, and I have a limitation on memory so I would rather use 1 Worker and 8 threads than 2 workers with 4 threads.

However, I still asking myself about a possible performance issue with a 1 worker configuration as on the Gunicorn official documentation recommend using the following setting.

2 * (number of cores) + 1

Considering the fact that with Python I'll be natively blocked by the GIL If I want true parallelism using threads, I still don't see any interest using more processes than the number of core.

1 Answers

This really depends on the workload.

For CPU intensive tasks, you're right. For I/O (Network, Storage) intensive tasks, you can utilize many threads to improve performance even on a single core.

This is all in theory, and performance bottlenecks can occur from unexpected sources.

The best thing to do in my opinion is empirically benchmark several configurations under workloads that simulate what the system will face in production, and choose the one that produced the best results.

Related