静态页面,带宽、cpu、内存占用都在 20%以下,服务器 ping 值 30ms 以下。但网页加载时快时慢,Chrome 排查发现当加载缓慢时,waiting(TTFB)最高时达 15s。以下为 nginx 配置,请问该如何优化?
worker_processes 2;
worker_cpu_affinity 0101 1010;
#pid logs/nginx.pid;
worker_rlimit_nofile 200134;
events {
worker_connections 200134;
multi_accept on;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
access_log off;
error_log /dev/null;
fastcgi on;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 20;
client_header_timeout 10;
client_body_timeout 10;
reset_timedout_connection on;
send_timeout 10;
open_file_cache max=200134 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 1;
open_file_cache_errors on;
server_tokens off;
gzip on;
worker_processes 2;
worker_cpu_affinity 0101 1010;
#pid logs/nginx.pid;
worker_rlimit_nofile 200134;
events {
worker_connections 200134;
multi_accept on;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
access_log off;
error_log /dev/null;
fastcgi on;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 20;
client_header_timeout 10;
client_body_timeout 10;
reset_timedout_connection on;
send_timeout 10;
open_file_cache max=200134 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 1;
open_file_cache_errors on;
server_tokens off;
gzip on;