V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Mask0c
V2EX  ›  问与答

Nigx 环境下在服务器使用率不到 20% 网站就 504 的假死状态,求解决思路。

  •  
  •   Mask0c · 2017-08-04 14:23:16 +08:00 · 1590 次点击
    这是一个创建于 2456 天前的主题,其中的信息可能已经有所发展或是发生改变。

    nginx.conf 的配置内容

    user www www;

    worker_processes auto;

    error_log /dzdata/wwwlogs/error_nginx.log crit; pid /var/run/nginx.pid; worker_rlimit_nofile 65535;

    events { use epoll; worker_connections 65535; multi_accept on; }

    http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 1024m; client_body_buffer_size 10m; sendfile on; tcp_nopush on; keepalive_timeout 120; server_tokens off; tcp_nodelay on;

    fastcgi_connect_timeout 2400; fastcgi_send_timeout 2400; fastcgi_read_timeout 2400; fastcgi_buffer_size 512k; fastcgi_buffers 4 512k; fastcgi_busy_buffers_size 1024k; fastcgi_temp_file_write_size 1024k; fastcgi_intercept_errors on;

    Gzip Compression# gzip on; gzip_buffers 16 8k; gzip_comp_level 6; gzip_http_version 1.1; gzip_min_length 256; gzip_proxied any; gzip_vary on; gzip_types text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml text/javascript application/javascript application/x-javascript text/x-json application/json application/x-web-app-manifest+json text/css text/plain text/x-component font/opentype application/x-font-ttf application/vnd.ms-fontobject image/x-icon; gzip_disable "MSIE [1-6].(?!.*SV1)";

    If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency.# open_file_cache max=65535 inactive=20s; open_file_cache_valid 30s; open_file_cache_min_uses 2; open_file_cache_errors on;

    ######################## default ############################ server { listen 80; servername ; access_log /dzdata/wwwlogs/access_nginx.log combined; root /dzdata/wwwroot/default; index index.html index.htm index.php;

    error_page 404 /404.html;# #error_page 502 /502.html; location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; deny all; } location ~ [^/].php(/|$) { #fastcgi_pass remote_php_ip:9000; fastcgi_pass unix:/dev/shm/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; } location ~ ..(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ { expires 30d; access_log off; } location ~ ..(js|css)?$ { expires 7d; access_log off; } location ~ /.ht { deny all; } } ########################## vhost ############################# include vhost/*.conf; }

    php-fpm.conf 配置内容

    ;;;;;;;;;;;;;;;;;;;;; ; FPM Configuration ; ;;;;;;;;;;;;;;;;;;;;;

    ;;;;;;;;;;;;;;;;;; ; Global Options ; ;;;;;;;;;;;;;;;;;;

    [global] pid = run/php-fpm.pid error_log = log/php-fpm.log log_level = warning

    emergency_restart_threshold = 30 emergency_restart_interval = 60s process_control_timeout = 5s daemonize = yes

    ;;;;;;;;;;;;;;;;;;;; ; Pool Definitions ; ;;;;;;;;;;;;;;;;;;;;

    [www] listen = /dev/shm/php-cgi.sock listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = www listen.group = www listen.mode = 0666 user = www group = www

    pm = dynamic pm.max_children = 192 pm.start_servers = 144 pm.min_spare_servers = 96 pm.max_spare_servers = 192 pm.max_requests = 4096 pm.process_idle_timeout = 10s request_terminate_timeout = 900 request_slowlog_timeout = 0

    pm.status_path = /php-fpm_status slowlog = log/slow.log rlimit_files = 51200 rlimit_core = 0

    catch_workers_output = yes ;env[HOSTNAME] = CTS5001 env[PATH] = /usr/local/bin:/usr/bin:/bin env[TMP] = /tmp env[TMPDIR] = /tmp env[TEMP] = /tmp#

    服务器的配置 CPU: Intel Xeon E5-2650*2 硬盘: 525GB SSD 内存: 64GB DDR3 ECC#

    PHP 线程:12000+的时候就挂了#

    服务器就 504 gateway time-out#

    求大神给个解决方法! TAT 很难过。

    3 条回复    2017-08-06 19:58:56 +08:00
    lzghades
        1
    lzghades  
       2017-08-04 15:24:18 +08:00
    只能说你的服务器配置好奢华。。。
    Mask0c
        2
    Mask0c  
    OP
       2017-08-05 00:55:08 +08:00
    @lzghades 有没有什么解决的办法?
    krisbai
        3
    krisbai  
       2017-08-06 19:58:56 +08:00 via iPhone
    worker_processes auto; 不配置下?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5400 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 07:45 · PVG 15:45 · LAX 00:45 · JFK 03:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.