8

I keep running into errors like these,

[02-Jun-2012 01:52:04] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 19 idle, and 49 total children
[02-Jun-2012 01:52:05] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 19 idle, and 50 total children
[02-Jun-2012 01:52:06] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 19 idle, and 51 total children
[02-Jun-2012 03:10:51] 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 91 total children

I changed my settings for php-fpm to these,

pm.max_children = 150 (It was at 100, i got a max_children reached and upped to 150)
pm.start_servers = 75
pm.min_spare_servers = 20
pm.max_spare_servers = 150

Resulting in

[02-Jun-2012 01:39:19] WARNING: [pool www] server reached pm.max_children setting (150), consider raising it

I've just launched a new website that is getting a conciderable amount of traffic on it. This traffic is legitimate and users are getting 504 gateway timeouts when the limit is reached.

I have limited connections to my server with IPTABLES and I'm running fail2ban and keeping track of nginx access logs. The traffic is all legitimate, i'm just running out of room for users.

I'm currently running on a dual core box with ubuntu 64bit.

free
             total       used       free     shared    buffers     cached
Mem:       6114284    5726984     387300          0     141612    4985384
-/+ buffers/cache:     599988    5514296
Swap:       524284       5804     518480

My php.ini max_input_time = 60

My nginx config is

worker_processes 4;
pid /var/run/nginx.pid;

events {
    worker_connections 19000;
    # multi_accept on;
}
worker_rlimit_nofile    20000;  #each connection needs a filehandle (or 2 if you are proxying)

client_max_body_size 30M;
client_body_timeout   10;
client_header_timeout 10;
keepalive_timeout     5 5;
send_timeout          10;

    location ~ \.php$ {
    try_files $uri /er/error.php;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_connect_timeout 60;
    fastcgi_send_timeout 180;
    fastcgi_read_timeout 180;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 256 16k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
    fastcgi_max_temp_file_size 0;
    fastcgi_intercept_errors on;
    fastcgi_pass unix:/tmp/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

What can I do to stop running out of connections? Why does this keep occurring? I'm monitoring my traffic on Google Analytics realtime and when the user count gets above about 120 my php-fpm.log is full of these warnings..

2 Answers 2

5

Have you considered following the fine advice provided in the log message, raising the value of pm.max_children? You've got bucketloads of free RAM to accomodate them.

To answer your questions:

  • What can I do to stop running out of connections? Provision more connections, or reduce the number of connections you receive.
  • Why does this keep occurring? Because you keep running out of connections.
2
  • Sorry, that error was timestamped after I had updated it to 150 from 100.... Yes i have. What setting should I set it to for all my ram?
    – E3pO
    Jun 2, 2012 at 1:25
  • You should raise it to (free/mem_per_worker)+150, where free is the amount of memory you will have after taking into account the needs of other processes whose memory requirements will increase with more load, and mem_per_worker is the maximum amount of memory you foresee each PHP worker process requiring.
    – womble
    Jun 2, 2012 at 1:28
3

We had the same issue on our webservers.

You can try to respawn the child process every X requests, to avoid memory leaks. It worked fine in Apache and FPM it's starting to work good as well.

 pm.max_requests = 50000

This will restart a child process every 50k requests

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .