About the optimal number of worker-shooters

A gunicorn

: I expected that the optimal number of workers would be $num_cores

or $num_cores-1

, that is, each worker has its own core. But guniorn documentation gives the following guidelines:

Gunicorn relies on the operating system to handle all load balancing when handling requests. We usually recommend (2 x $ num_cores) + 1 as the number of workers to start with. While not a super-scientific formula, it is based on the assumption that, for a given kernel, one worker will read or write from the socket while another worker processes the request.

I don't understand the explanation. Does this mean that the same kernel can be used simultaneously to 1) read or write from a socket AND 2) process a request? (Can a single core do such a thing?)

+3


source to share


1 answer


The answer is based on processes waiting for the event.

For example, the kernel does nothing when you call the SQL server. Having an extra worker per kernel means that the kernel scheduler can use time with another process.



You will get more RPS this way.

If you know where time goes by request with good details and your download patterns, you can further modify this to suit your needs.

+4


source







All Articles