Nginx 서버는 하루 동안 성능이 저하됩니다.

Nginx 서버는 하루 동안 성능이 저하됩니다.

서버 속도가 느려지는 문제가 매일 발생하고 있습니다. 나는 이것이 nginx 또는 php-fpm이 어느 시점에서 포기하고 정상적으로 복구되지 않는 문제라고 생각합니다. 도움이 될 수 있는 모든 정보를 포함하겠습니다. nginx 및 php-fpm 설정부터 시작하겠습니다. 여기에 게시하는 데 도움이 될 만한 다른 내용이 있으면 알려 주시기 바랍니다. 진단에 도움이 될 수 있다면 cloudflare를 사용합니다.

또한 아래 정보가 충분하지 않은 경우 이유를 알아내는 방법에 대한 제안도 받습니다.

웹사이트는여기

편집하다: 모든 요청은 nignx 또는 php가 사용할 수 있지만 해제하지는 않는 설정된 양의 리소스를 사용하기 시작하는 것처럼 보입니다. 내 모니터링에서는 top서버가 느리게 응답하기 시작할 때 CPU 또는 메모리의 스파이크가 표시되지 않습니다. 어느 시점에서 속도 저하로 인해 시간 초과가 발생하고 5XX 오류가 반환됩니다.

linode에서 호스팅되는 서버가 있습니다. 사양은 다음과 같습니다.

8 GB RAM
6 CPU Cores
192 GB SSD Storage
8 TB Transfer
40 Gbps Network In
1000 Mbps Network Out

nginx.conf

user www-data www-data;
worker_processes 6;
pid /run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {

##
# Basic Settings
##
    # set client body size to 2M #  
    client_max_body_size 50M;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
# added cbt, cht, st -- kt was there
keepalive_timeout 5;
types_hash_max_size 2048;
server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

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

##
# Logging Settings
##
log_format cf_custom '$remote_addr - $remote_user [$time_local]  '
                '"$request" $status $body_bytes_sent '
                '"$http_referer" "$http_user_agent" '
                '$http_cf_ray';

#access_log /var/log/nginx/access.log;
#error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

gzip_vary on;
gzip_proxied any;
gzip_comp_level 5;
# gzip_buffers 16 8k;
gzip_http_version 1.0;
# Gzip the following types of requests/files
gzip_types application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml  image/x-icon text/css text/plain text/x-component;

##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##

#include /etc/nginx/naxsi_core.rules;

##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##

#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;

##
# Virtual Host Configs
##

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

# Cloudflare
set_real_ip_from 199.27.128.0/21;
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 188.114.96.0/20; 
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 104.16.0.0/12;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 2400:cb00::/32;
set_real_ip_from 2606:4700::/32;
set_real_ip_from 2803:f800::/32;
set_real_ip_from 2405:b500::/32;
set_real_ip_from 2405:8100::/32;
real_ip_header CF-Connecting-IP;        
}

php-fpm.conf

[global]
pid = /var/run/php5-fpm.pid
error_log = /var/log/php5/fpm.log
log_level = debug 
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 10
process.max = 128
include=/etc/php5/fpm/pool.d/*.conf

www.conf

[www]

user = www-data
group = www-data

listen = /var/run/php5-fpm.sock

listen.owner = www-data
listen.group = www-data
listen.mode = 0660

pm = ondemand

pm.max_children = 26

pm.start_servers = 8

pm.min_spare_servers = 5

pm.max_spare_servers = 11

pm.process_idle_timeout = 10s;

pm.max_requests = 50
slowlog = /var/log/php5/slow.log
request_slowlog_timeout = 10s
request_terminate_timeout = 360s
;rlimit_files = 1024
rlimit_core = unlimited

chdir = /                                                                                                                                                           

맨 위

top - 14:39:10 up  1:04,  2 users,  load average: 1.47, 1.28, 1.28
Tasks: 187 total,   3 running, 183 sleeping,   1 stopped,   0 zombie
%Cpu(s): 16.0 us,  4.8 sy,  0.0 ni, 79.1 id,  0.0 wa,  0.0 hi,  0.1 si,  0.1 st
KiB Mem:   8206476 total,  7661580 used,   544896 free,  2386564 buffers
KiB Swap:   524284 total,     1328 used,   522956 free.   680268 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                                                                                              
 1653 root      20   0  284736  41136  15176 S   6.3  0.5   0:00.19 php5                                                                                                                                                                                                                 
 1659 root      20   0  285048  42040  15672 S   6.3  0.5   0:00.19 php5                                                                                                                                                                                                                 
 1668 root      20   0  285048  42076  15704 S   6.3  0.5   0:00.19 php5                                                                                                                                                                                                                 
 1676 root      20   0  285048  41956  15588 S   6.3  0.5   0:00.19 php5                                                                                                                                                                                                                 
 1645 root      20   0  284732  41060  15108 S   6.0  0.5   0:00.18 php5                                                                                                                                                                                                                 
 1649 root      20   0  284732  41480  15520 S   6.0  0.5   0:00.18 php5                                                                                                                                                                                                                 
 1656 root      20   0  284736  41336  15376 S   6.0  0.5   0:00.18 php5                                                                                                                                                                                                                 
 1664 root      20   0  284736  41320  15360 S   6.0  0.5   0:00.18 php5                                                                                                                                                                                                                 
 1680 root      20   0  284736  41332  15368 S   6.0  0.5   0:00.18 php5                                                                                                                                                                                                                 
 1684 root      20   0  280172  38288  14816 R   5.3  0.5   0:00.16 php5                                                                                                                                                                                                                 
 1222 www-data  20   0  351712  80236  64044 S   4.3  1.0   0:00.64 php5-fpm                                                                                                                                                                                                             
 1065 www-data  20   0  351680  79912  63768 S   3.7  1.0   0:00.79 php5-fpm                                                                                                                                                                                                             
 1215 www-data  20   0  351548  68972  52844 S   3.7  0.8   0:00.58 php5-fpm                                                                                                                                                                                                             
 1484 www-data  20   0  349536  65116  49748 S   3.7  0.8   0:00.23 php5-fpm                                                                                                                                                                                                             
  502 www-data  20   0  351604  69484  53932 S   2.7  0.8   0:01.26 php5-fpm                                                                                                                                                                                                             
 1496 www-data  20   0  349532  65248  49748 S   2.7  0.8   0:00.23 php5-fpm                                                                                                                                                                                                             
31105 www-data  20   0  351776  81428  65260 S   2.7  1.0   0:02.92 php5-fpm                                                                                                                                                                                                             
 3194 www-data  20   0   88216   7788   4440 S   2.3  0.1   0:09.70 nginx                                                                                                                                                                                                                
31652 www-data  20   0  352180  82120  65644 S   2.3  1.0   0:02.73 php5-fpm                                                                                                                                                                                                             
  512 www-data  20   0  347204  71160  57300 S   2.0  0.9   0:01.14 php5-fpm                                                                                                                                                                                                             
  980 www-data  20   0  351712  80484  64300 S   2.0  1.0   0:00.82 php5-fpm                                                                                                                                                                                                             
 1639 root      20   0  285048  41864  15492 S   2.0  0.5   0:00.19 php5                                                                                                                                                                                                                 
31275 www-data  20   0  349020  78496  64812 S   2.0  1.0   0:03.20 php5-fpm                                                                                                                                                                                                             
32114 www-data  20   0  351628  78468  62316 S   2.0  1.0   0:01.93 php5-fpm                                                                                                                                                                                                             
  588 www-data  20   0  352940  82800  66476 S   1.7  1.0   0:01.64 php5-fpm                                                                                                                                                                                                             
30959 www-data  20   0  351816  83404  67180 S   1.7  1.0   0:03.43 php5-fpm                                                                                                                                                                                                             
31736 www-data  20   0  349788  68604  54188 S   1.7  0.8   0:02.50 php5-fpm                                                                                                                                                                                                             
 3129 mysql     20   0 3441720 208516  11144 S   1.3  2.5   1:23.69 mysqld                                                                                                                                                                                                               
  840 www-data  20   0  349788  76684  62444 R   1.0  0.9   0:00.84 php5-fpm                                                                                                                                                                                                             
 3617 root      20   0  560496  12724   5328 S   0.7  0.2   0:21.73 fail2ban-server                                                                                                                                                                                                      
    7 root      20   0       0      0      0 S   0.3  0.0   0:04.87 rcu_sched                                                                                                                                                                                                            
 1462 root      20   0       0      0      0 S   0.3  0.0   0:03.17 kworker/4:1                                                                                                                                                                                                          
 1635 root      20   0  285048  41928  15556 S   0.3  0.5   0:00.19 php5                                                                                                                                                                                                                 
 3299 root      20   0  279628  37576  14760 S   0.3  0.5   0:11.20 php                                                                                                                                                                                                                  
 3301 root      20   0  279628  37616  14800 S   0.3  0.5   0:11.24 php                                                                                                                                                                                                                  
 3304 root      20   0  279628  37652  14840 S   0.3  0.5   0:11.16 php                                                                                                                                                                                                                  
 3305 root      20   0  279628  37528  14712 S   0.3  0.5   0:11.04 php                                                                                                                                                                                                                  
 3307 root      20   0  279628  37620  14804 S   0.3  0.5   0:11.06 php                                                                                                                                                                                                                  
 3309 root      20   0  279628  37696  14880 S   0.3  0.5   0:11.27 php                                                                                                                                                                                                                  
 3313 root      20   0  278344  36640  15032 S   0.3  0.4   0:10.60 php                                                                                                                                                                                                                  
 3314 root      20   0  278344  36560  14952 S   0.3  0.4   0:10.57 php                                                                                                                                                                                                                  
 3319 root      20   0  278344  36632  15024 S   0.3  0.4   0:10.63 php                                                                                                                                                                                                                  
 3333 root      20   0  278344  36672  15068 S   0.3  0.4   0:10.41 php                                                                                                                                                                                                                  
    1 root      20   0   33652   4196   2724 S   0.0  0.1   0:03.96 init                                                                                                                                                                                                                 
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kthreadd                                                                                                                                                                                                             
    3 root      20   0       0      0      0 S   0.0  0.0   0:00.17 ksoftirqd/0                                                                                                                                                                                                          
    4 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0                                                                                                                                                                                                          
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H                                                                                                                                                                                                         
    6 root      20   0       0      0      0 S   0.0  0.0   0:01.13 kworker/u12:0                                                                                                                                                                                                        
    8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh                                                                                                                                                                                                               
    9 root      rt   0       0      0      0 S   0.0  0.0   0:00.05 migration/0                                                                                                                                                                                                          
   10 root      rt   0       0      0      0 S   0.0  0.0   0:00.05 migration/1                                                                                                                                                                                                          
   11 root      20   0       0      0      0 S   0.0  0.0   0:00.07 ksoftirqd/1                                                                                                                                                                                                          
   12 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kworker/1:0                                                                                                                                                                                                          
   13 root       0 -20       0  

iostat

Linux 4.1.5-x86_64-linode61 (localhost)     09/29/2015  _x86_64_    (6 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          16.05    0.00    5.52    0.12    0.12   78.19

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
xvda             74.76       321.33       285.55    3117199    2770120
xvdb              0.02         0.06         0.14        572       1336

iostat -x 1 -- 느릴 때

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
xvda              0.00     0.00    0.00    7.00     0.00    28.00     8.00     0.00    0.43    0.00    0.43   0.57   0.40
xvdb              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          25.84    0.00    8.22    0.00    0.17   65.77

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
xvda              0.00    55.00    0.00   10.00     0.00   264.00    52.80     0.00    0.40    0.00    0.40   0.30   0.30
xvdb              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           8.68    0.00    4.17    0.00    0.00   87.15

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
xvda              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00
xvdb              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          10.18    0.00    5.01    0.00    0.00   84.81

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
xvda              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00
xvdb              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          18.06    0.00    5.52    0.00    0.00   76.42

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
xvda              0.00     0.00    0.00    3.00     0.00    12.00     8.00     0.00    0.00    0.00    0.00   0.00   0.00
xvdb              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          17.47    0.00    6.82    0.00    0.17   75.54

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
xvda              0.00     0.00    0.00    7.00     0.00    28.00     8.00     0.00    0.43    0.00    0.43   0.43   0.30
xvdb              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          15.55    0.00    3.34    0.00    0.00   81.10

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
xvda              0.00   105.00    0.00   21.00     0.00   696.00    66.29     0.00    0.14    0.00    0.14   0.19   0.40
xvdb              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00

관련 정보