Nginx – Can not optimize php5-fpm to work without errors

nginxphp-fpm

I have installed ngix + php5-fpm. I am happy with it but I can not optimize php5-fpm so that it works without errors. Each fixed error creates a different error.

First I had the the default settings which causet a lot of errors:

[04-Jun-2012 03:30:06] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it

I increased all numbers:

pm.max_children = 15
pm.start_servers = 5
pm.min_spare_servers = 3
pm.max_spare_servers = 5
;pm.max_requests = 500

It caused a different error:

[28-Feb-2013 07:45:06] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 18 idle, and 28 total children

I increased all numbers again:

pm.max_children = 70
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 35
;pm.max_requests = 500

This caused logfile filling up with this:

[28-Feb-2013 13:21:55] NOTICE: [pool www] child 21868 exited with code 0 after 4171.293476 seconds from start
[28-Feb-2013 13:21:55] NOTICE: [pool www] child 23962 started

I uncommented:

pm.max_requests = 500

I had the same errors, but not so often – every 5 minutes:

[28-Feb-2013 13:21:55] NOTICE: [pool www] child 21868 exited with code 0 after 4171.293476 seconds from start
[28-Feb-2013 13:21:55] NOTICE: [pool www] child 23962 started

I did increase again:

pm.max_requests = 1000

Now I have this error 2-3 times per hour but it still persists.

I would increase this number again but I feel that my server (websites) work a bit slower than websites hosted on another server with settings: pm.max_children = 15,pm.start_servers = 5, pm.min_spare_servers = 3, pm.max_spare_servers = 5. (probably it's just a network issue, I don't know).

I have searched Google and this website and know how to calculate the pm.max_children (it depends of RAM). But I can not find any information how to calculate:

    pm.start_servers
    pm.min_spare_servers
pm.max_spare_servers
    pm.max_requests

Can somebody help?

uptime
 13:55:39 up 16:40,  2 users,  load average: 0.13, 0.14, 0.16


free -m
             total       used       free     shared    buffers     cached
Mem:         24101       3783      20318          0        151       3039
-/+ buffers/cache:        592      23509
Swap:         7811          0       7811

I did not change anything in nginx configuration files.

Best Answer

As it says in the log [NOTICE]: this is informational and not an error. These are marked [ERROR].

So in short: nothing to worry about. It's like your kid telling you they switched off the light in the kitchen.

If it says [WARNING] that's something you should take care of, like you did in your first response by increasing the thresholds.