Maximum php-fpm threads per one core
I would like to ask how to get the best (maximum) number of php-fpm threads per one core? How to benchmark it (on linux/debian)? And how to recognize that this count is already too much? Thank you.
You probably mean processes in the pool. This depends primarily on how much blocking does your actual PHP code. The more it just waits, the more processes you need to have, because more children will just block and wait for something (for example - for external HTTP requests to end). This actual number does depend on the amount of memory you have, on the other hand. The basic rule 2-4 processes per core applies to some ideal code that doesn't block much. Of course you can determine the formal number of threads per core by looking at the specs of your CPU, for instance # of Threads per core for Intel E5-2640 CPU would be 2.
The simple approach on determining the actual number of children in the pool is simple: make it #of Threads for your CPU at the start, then increase slightly, while repeating the benchmarking test for your installation. Once the performance stops to increase, or once you hit the memory cap, stop increasing.
Also keep in mind that in a situation when some external resource will hit it's cap or become unresponsive (i.e. - database server, or some external HTTP server that your code may query) - you will hit the cap no matter how much children in the pool you have, they will just stuck in a waiting state. So you should keep in mind this possible bottleneck while determining your pool cap.