3

Recently inherited a Nginx+PHP5-FPM server, and I'm learning and trying to optimize PHP5-FPM settings.

Server info:

4 CPUs (8 threads)
7.5 GiB RAM

PHP5-FPM info:

pm.max_children = 5
pm.min_spare_servers = 1
pm.max_spare_servers = 3
;pm.process_idle_time = 10s;
;pm.max_requests = 500

(I'm going to uncomment the max_requests line, since that appears to be a recommended thing to do.)

When the website is under load, each PHP5-FPM process has very high CPU usage but I have yet to see a process go over 1% RAM usage.

Everywhere that I look (eg here and here) only talks about increases of pm.max_children being limited by RAM, and doesn't mention CPU usage.

In my case, would increasing pm.max_children increase or decrease my website's performance, based on the fact that it is more CPU bound than RAM bound? In other words, as pm.max_children increases is RAM the only consideration or is CPU also affected?

[Edit] Not a duplicate: The question basically boils down to the final sentence, which is not asking for advice about capacity planning; it is asking if CPU usage is a consideration in the pm.max_children setting or if it is solely RAM that is increased.

Anthony F.
  • 153
  • 1
  • 6
  • possible duplicate of [Can you help me with my capacity planning?](http://serverfault.com/questions/384686/can-you-help-me-with-my-capacity-planning) – Deer Hunter Jul 06 '15 at 20:48
  • Not really. The question basically boils down to the final sentence, which is not asking for advice about capacity planning; it is asking if CPU usage is a consideration in the `pm.max_children` setting or if it is solely RAM that is increased. – Anthony F. Jul 06 '15 at 21:03
  • @DeerHunter Looks like a performance tuning question to me, not a capacity planning question. – Michael Hampton Jul 08 '15 at 14:05

2 Answers2

0

From my point of view your children limit is way too low. If you have enough memory (and each child usually consumes only small amount) the number of children should be set at least to cores*2. I'd recommend setting max-children to 32.

drookie
  • 8,051
  • 1
  • 17
  • 27
0

It depends on what your PHP scripts are doing. But 5 is really low number for PHP processes. Usually the PHP process will open connection to MySQL (takes time), wait for MySQL to process the query (takes time), so it won't be using CPU all the time and with only 5 processes the CPU can be idle some moments, but there will be no other PHP process to use it. So you can safely increase the limit to at least 20-30 (or more, depending on how manuy req/s you receive).

Regarding the question on CPU usage. Having more active PHP processes at the same time won't increase the CPU usage. All the CPU power you have available will be divided between running processes.

Marki555
  • 1,488
  • 1
  • 14
  • 27