I'm currently running Nginx + PHP-FPM in my server for my websites. Today when I run Apache "ab" tool I noticed horrible response times, average 5595 and max 17415ms to respond.
My Nginx config file:
worker_processes 4; error_log /var/log/nginx/error.log info; events { worker_connections 1024; use epoll; multi_accept on; } http { server_name_in_redirect off; server_names_hash_max_size 10240; server_names_hash_bucket_size 1024; include mime.types; default_type application/octet-stream; index index.html index.htm index.php; server_tokens off; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 15; gzip on; gzip_vary on; gzip_disable "MSIE [1-6]\."; gzip_proxied any; gzip_http_version 1.1; gzip_min_length 1400; gzip_comp_level 9; gzip_buffers 16 8k; gzip_types text/plain text/xml text/css application/x-javascript application/xml image/png image/x-icon image/gif image/jpeg application/xml+rss text/javascript application/atom+xml; ignore_invalid_headers on; client_header_timeout 10m; client_body_timeout 10m; send_timeout 10m; recursive_error_pages on; keepalive_requests 100; reset_timedout_connection on; connection_pool_size 256; client_header_buffer_size 256k; large_client_header_buffers 4 256k; client_max_body_size 200M; client_body_buffer_size 128k; request_pool_size 32k; output_buffers 4 32k; postpone_output 1460; proxy_temp_path /tmp/nginx_proxy/; client_body_in_file_only on; log_format bytes_log "$msec $bytes_sent ."; ## Proxy options proxy_buffering on; proxy_cache_min_uses 3; proxy_cache_path /etc/nginx/proxy_temp/ levels=1:2 keys_zone=cache:10m inactive=10m max_size=1000M; proxy_cache_valid any 10m; proxy_ignore_client_abort off; proxy_intercept_errors on; proxy_next_upstream error timeout invalid_header; proxy_redirect off; proxy_set_header X-Forwarded-For $remote_addr; proxy_connect_timeout 60; proxy_send_timeout 60; proxy_read_timeout 60; include "/etc/nginx/vhosts/*"; }
My PHP-FPM config (only relevant parameters):
pm = dynamic pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 50 [..] php_admin_value[cgi.fix_pathinfo] = 0 php_admin_value[memory_limit] = 128M
My Server
CPU Intel i3-540 3.06GHz with 4 processors 6GB RAM CentOS 5.6 x64 # ulimit -n 65535
Benchmark ploted graphic http://imm.io/awLk
Almost forgot, the php-fpm is handled by nginx:
server { [..] location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name; fastcgi_param SERVER_NAME $http_host; fastcgi_ignore_client_abort off; } [..] }
Does anyone have any tips on how I can optimize it?