请教如何排查 nginx 未响应情况

2022-12-05 15:54:51 +08:00
 zonas

我是开发者,目前不知道往哪方面查,请广大 v 友提供思路

问题与现状

不定期出现访问未响应情况,持续时间几分钟,期间 nginx 映射所有访问不了,并服务器也 ssh 不上,日志没出现 Too many open files 等任何报错

服务器:阿里 ecs.g7.large ,2 核 8G 内存

nginx 自己编译

nginx version: nginx/1.22.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/home/nginx --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_sub_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-pcre --with-pcre-jit --with-debug

部署服务:很多静态文件,但不是 js 、css 这些

访问量:不太清楚怎么算

目前排查情况

  1. 调整过 worker_connections 不起作用
  2. 在未响应期间,看 cpu 指标,没有明显新增,看 tcp 连接数 ESTABLISHED 和 TIME_WAIT 也不多,因不太懂 tcp 这块,不知是不是这块问题

nginx 核心配置 摘要

#user  nobody;
worker_processes  2;
worker_cpu_affinity auto;

pid        logs/nginx.pid;
error_log   /home/nginx/logs/error.log notice;

worker_rlimit_nofile 8192;
events {
    worker_connections  4096;
    multi_accept on;
    accept_mutex on;
    use epoll;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    charset utf-8;

    #access_log  logs/access.log  main;
    server_tokens off;
    sendfile       on;
    tcp_nopush on;
    tcp_nodelay on;

    server_names_hash_bucket_size 128;
    server_names_hash_max_size 512;

    keepalive_timeout  65;
    send_timeout 30s;

    client_header_timeout 15;
    client_body_timeout 15;
    reset_timedout_connection on;

    proxy_connect_timeout 5s;
    proxy_send_timeout 120s;
    proxy_read_timeout 120s;

    gzip on;
    gzip_min_length  1k;
    gzip_buffers     4 32k;
    gzip_http_version 1.1;
    gzip_comp_level 4;
    gzip_types text/css text/xml application/javascript;
    gzip_vary on;
    gzip_disable "MSIE [1-6].";

    include /home/nginx/conf/conf.d/*.conf;
}
2759 次点击
所在节点    NGINX
45 条回复
zonas
2022-12-07 12:23:46 +08:00
@mytsing520 这个之前的确设 1 ,我改成 0 看看有没有好转
Ggmusic
2022-12-07 22:53:57 +08:00
tcp_tw_recycle 的坑踩过,网上有人给出过总结。http://blog.51cto.com/leejia/1954628
zonas
2022-12-08 12:53:59 +08:00
@Ggmusic 这么一看感觉和我问题很相似,感谢
skyone123
2022-12-08 23:34:38 +08:00
有效果吗
@zonas
zonas
2022-12-09 08:38:54 +08:00
@skyone123 的确有效果,现在几乎没出现这个问题

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/900260

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX