在加载网页资源的过程中,nginx 延迟变得越来越严重,这正常吗?

在加载网页资源的过程中,nginx 延迟变得越来越严重,这正常吗?

如果我打开 Chrome devtools 并转到网络面板,然后对我的网站执行 ctrl+F5,我每次都会注意到一个模式。

第一个请求(对 php 页面)的延迟(等待)时间为 74 毫秒。ping 我的服务器需要 35 毫秒,因此我很高兴查找和提供 php 页面的开销只有 40 毫秒左右。

但随着页面继续加载资产,大多数资产需要约 200 毫秒。静态 jpeg/css/js 等。

这是“正常的”吗?如果是,那么原因是什么?

如果我直接浏览图像(因此我只加载 jpeg 而不加载其他内容),则该请求的延迟往往在 60-70 毫秒范围内。

我通过 SPDY 为网站提供服务,但禁用它似乎没有什么区别

这是我的 nginx.conf 文件:

pid                 /var/run/nginx.pid;
user                nginx nginx;
worker_processes    6;

error_log           /var/log/nginx/error.log;

events {
    use epoll;
    worker_connections 1024;
}


http {
server_tokens               off;

client_max_body_size        50m;

ssl_session_cache           shared:SSL:10m;
ssl_session_timeout         20m;
ssl_protocols               TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers                 "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
ssl_prefer_server_ciphers   on;
ssl_certificate             /etc/pki/tls/certs/ssl-bundle.crt;
ssl_certificate_key         /etc/pki/tls/private/STAR_mydomain_com.key;
ssl_stapling                on;
ssl_stapling_verify         on;
ssl_dhparam                 /etc/ssl/certs/dhparam.pem;

charset                     utf-8;
source_charset              utf-8;

include                     /etc/nginx/mime.types;
default_type                application/octet-stream;

log_format                  main    '$https $remote_addr - $remote_user [$time_local] "$request" '
                                    '$status $body_bytes_sent $bytes_sent "$http_referer" '
                                    '"$http_user_agent" "$http_x_forwarded_for"';
access_log                  /var/log/nginx/access.log  main;

sendfile                    on;
keepalive_timeout           75s;
keepalive_requests          100;
open_file_cache             max=100;

etag                        off;

gzip                        on;
gzip_http_version           1.1;
gzip_comp_level             1;
gzip_static                 on;
gzip_types                  text/plain text/css application/json
                            application/x-javascript text/xml application/xml
                            application/xml+rss text/javascript image/svg+xml
                            application/vnd.ms-fontobject application/x-font-ttf
                            font/opentype;

index                       index.php index.html;


fastcgi_read_timeout        600s;


include /etc/nginx/sites-enabled/*.conf;
include /etc/nginx/conf.d/*.conf;
}

nginx 版本:

nginx version: nginx/1.6.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx
--conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log 
--http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid 
--lock-path=/var/run/nginx.lock 
--http-client-body-temp-path=/var/cache/nginx/client_temp 
--http-proxy-temp-path=/var/cache/nginx/proxy_temp 
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp 
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp 
--http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx 
--group=nginx --with-http_ssl_module --with-http_realip_module 
--with-http_addition_module --with-http_sub_module --with-http_dav_module 
--with-http_flv_module --with-http_mp4_module --with-http_gunzip_module 
--with-http_gzip_static_module --with-http_random_index_module 
--with-http_secure_link_module --with-http_stub_status_module 
--with-http_auth_request_module --with-mail --with-mail_ssl_module 
--with-file-aio --with-ipv6 --with-http_spdy_module 
--with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions 
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'

Devtools 瀑布图:

定时器瀑布

相关内容