Answer the question
In order to leave comments, you need to log in
How to calculate the optimal number of workers for maximum performance with a given hardware?
On 4 (or n - processors) processor hardware, a certain number of workers - demons are spinning.
You need to find the optimal number of workers, if the worker serves only one connection in one period of time (single-threaded daemon on blocked sockets), I
want to understand the approach,
Answer the question
In order to leave comments, you need to log in
Judging by John Allspou's book The Art of Capacity Planning , you need to initially set the nth number of workers (for example, from some setup guide) and smoothly try to increase or decrease them, observing the behavior of the main metrics, for example. memory, processor and disk I\O.
In general, I strongly advise you to read this book, you will definitely understand the approaches to capacity planning.
If a worker uses only 25% of the cpu out of the real time spent processing a request, then it is worth running four times more workers than the number of cores. Plus or minus. Usually there is still an additional load, such as databases, so you can set a slightly lower value.
For workers that use cpu efficiently without blocking during work, you just need to set the number of cores accordingly.
experimenting with the number of uWSGI workers in a Python (Django) application, I found out that the optimal number of workers (for my application) is equal to the number of cores.
Tested through the ab utility.
If my application had tasks that wait a long time for a response and do not strain the percentage at the same time (parsing the site, waiting for a response from the database from another server, etc.), then the number of workers would have to be increased.
In other words, my approach is an experiment. We take something average recommended and smoothly try to carefully change, observe, analyze, draw conclusions, make a decision.
I remember Sysoev in the nginx mailing list mentioned that the number of workers can be set equal to the number of cores, but you should not get carried away with this, because. due to movement in the process of work on the cores, efficiency may drop. Therefore, as a first approximation, it is still worth focusing on the number of cores.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question