nginx connection time issue on some IPs

Posted by sheldon on Server Fault See other posts from Server Fault or by sheldon
Published on 2011-11-13T13:16:02Z Indexed on 2011/11/13 17:54 UTC
Read the original article Hit count: 344

Filed under:
|

I have recently shifted my server to nginx and php-fpm getting rid of apache. This has helped improves speeds of my website.

Everything seems to work fine until i came across this issue, i noticed that nginx keeps throwing connection time out errors for only certain IPs. One of the IPs is my office IP, we have a backend that is accessed from our office through out the day.

I use supervisord to launch 3 php-fpm processes with workers this is my typical php-fpm config

pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 300

Since i have a server with 4 cores and 2 GB ram this is my nginx setup

worker_processes  4;
worker_rlimit_nofile 8192;
events {
   worker_connections  1024;
   use epoll;
   multi_accept off;
}
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 55;
recursive_error_pages    on;
server_name_in_redirect off;
server_tokens           off;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size 256;
client_header_buffer_size 8k;
large_client_header_buffers 4 32k;
request_pool_size 4k;
output_buffers   4 32k;
postpone_output  1460;
proxy_buffer_size          32k;
proxy_buffers              4 32k;
proxy_busy_buffers_size    64k;
proxy_temp_file_write_size 64k;
fastcgi_connect_timeout 120;
fastcgi_send_timeout 120;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort     off;

Where am i going wrong with the config, I have tried various settings but the issue still persists.

These are the errors i keep getting

2011/11/13 18:20:33 [error] 21583#0: *311683 upstream timed out (110: Connection timed   out) while reading response header from upstream, client: IP, server: tastykhana.in, request: "GET url HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.socket:", host: "tastykhana.in", referrer: "url"

© Server Fault or respective owner

Related posts about nginx

Related posts about php-fpm