简体   繁体   中英

Correct number of workers for Gunicorn

According to the Gunicorn's documentation , the number of workers recommended are (2 * #cores) + 1 .

They have provided the following explanation:

Generally we recommend (2 x $num_cores) + 1 as the number of workers to start off with. While not overly scientific, the formula is based on the assumption that for a given core, one worker will be reading or writing from the socket while the other worker is processing a request.

According to the above logic, 2 workers/processes (as a worker is a process) share the same core. Then where did the additional 1 came from?

Secondly, 2 processes are sharing the same core. Isn't this a bad architecture?

Additional worker is for handling the overhead of managing the other workers.

Regarding the architecture, it is not uncommon for multiple processes to share the same CPU core, especially in cases where the number of processes exceeds the number of cores. This is known as hyperthreading, and it allows the CPU to switch between multiple processes more quickly, improving overall performance. However, the degree to which hyperthreading can improve performance can vary depending on the specific workload and hardware.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM