How many PHP children is too many?
But I'm thinking of leaving the # of children alone, since the real bottleneck is the database. And I'm thinking MySQL won't necessarily perform better if more children are opening more connections.
So how many PHP children is too many? Or do you think it's best to have as many PHP children as I can fit into memory?
One item in the status report is 'max children reached'. If you see that number incrementing then you may want to increase the number of children.
My rule of thumb is 1.5n to 2.0n children, where n is the number of cores in the system, but I haven't based that on anything in particular as much as gut feeling and "seems to work well for me".
Great, I have about that many. I'll leave it alone then.
Not exactly sure how many cores I have but I'm guessing it's either 4 or 8.
@sleddog I'll keep that in mind but I'm actually using spawn on this server. (If it ain't broke…)
I guess general rule is that if your site is sometimes getting non-responsive because all PHP handlers are busy waiting (not as much if busy processing), and you have RAM for it… add more.
I have been running 20 PHP children on a pre-upgrade 4-core Li512, because some of them are usually just stuck waiting for the DB, or for a http transfer to complete.
To work it out is pretty simple. When running your application under "normal" load:
ps -ylC php5-fpm –sort:rss
RSS column will show non-swapped physical memory usage by php5-fpm processes in KB. So, best value for pm.max_children can be calculated as:
pm.max_children = Total RAM dedicated to the web server / Max child process size. In my case it was around 50MB per process, and if I wanted to leave 768MB for php5-fpm:
pm.max_children = 768MB / 50MB = 15.
pm.start, min etc just requires tweaking. Keep in mind you'll need to redo this with any major application (php) upgrade, php config change (xcache settings etc).
If you want to test high load: