我试图诊断与debian上的nginx的连接问题。 有连接2-10秒的任何延迟,即时通讯使用curl来testing:
curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" -s http://example.com/forumhome.css Connect: 0.657 TTFB: 1.183 Total time: 7.150
这是上面的curl请求的tcpdump输出的一个pastebin: http : //pastebin.com/2tdZHqFr
我也testing过使用webpagetest.org从不同的位置,并存在相同的连接问题。
这些文件是从安装在另一台机器上的ssd提供的。
Linux main 2.6.32-5-amd64#1 SMP Wed May 18 23:13:22 UTC 2011 x86_64 GNU / Linux
nginx conf:
user www-data; worker_processes 4; worker_rlimit_nofile 802768; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; events { use epoll; worker_connections 60000; multi_accept on; } http { include /etc/nginx/mime.types; # access_log /var/log/nginx/access.log; access_log off; sendfile off; keepalive_timeout 75; tcp_nodelay on; keepalive_requests 2000; connection_pool_size 8192; client_body_buffer_size 1024K; client_header_buffer_size 8k; client_max_body_size 10M; fastcgi_buffers 4 256k; fastcgi_buffer_size 128k; fastcgi_busy_buffers_size 256k; large_client_header_buffers 8 8k; ignore_invalid_headers on; client_header_timeout 60; client_body_timeout 60; send_timeout 60; output_buffers 8 32k; postpone_output 0; server_name_in_redirect off; server_tokens off; tcp_nopush on; gzip on; gzip_min_length 1100; gzip_buffers 32 8k; gzip_comp_level 2; gzip_types text/plain text/html application/x-javascript text/xml text/css text/javascript; gzip_vary on; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }
sysctl here – > pastebin systcl
site.conf:
open_file_cache max=5000 inactive=20s; open_file_cache_valid 30s; open_file_cache_min_uses 2; open_file_cache_errors on; server { listen 80 ; ## listen for ipv4 server_name example.com; root /mnt/ssd/www/static; location ~* \.(css|js)$ { expires max; add_header Pragma public; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; } }
ifconfig eth0:
eth0 Link encap:Ethernet HWaddr 00:15:17:26:b4:bd inet addr:xxxx Bcast:xxxx Mask:255.255.254.0 inet6 addr: fe80::215:17ff:fe26:b4bd/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:9000 Metric:1 RX packets:1136534270 errors:0 dropped:0 overruns:0 frame:0 TX packets:623191419 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:174357516836 (162.3 GiB) TX bytes:323522620298 (301.3 GiB) Memory:e1a00000-e1a20000
cat / proc / cpuinfo:
model name : Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz
cat / proc / meminfo:
MemTotal: 4058884 kB MemFree: 3366684 kB Buffers: 117632 kB Cached: 288320 kB
最好检查你的转发和(尤其是)反向DNS查找。 这是“慢”的通常原因。