PHP-FPM 수신 대기열에 의해 사이트에 액세스할 수 없게 되어 CPU가 100%에 도달합니다.
1개의 Wordpress 블로그를 호스팅하는 프로덕션 서버에서 몇 시간마다 랜덤하게 발생하는 이 문제를 해결하기 위해 머리를 짜내고 있습니다(트래픽은 적당합니다.평균일당 2,000명, 좋은 날은 5,000명 이상, 분당 페이지뷰는 300~700명 이상).
Newrelic을 사용하여 퍼포먼스를 감시하고 있는데 특이한 점이 있습니다.
몇 시간마다(랜덤하게) PHP-FPM 풀의 상태는 다음과 같습니다(어제 실제 상태가 캡처됨).
pool: www
process manager: static
start time: 02/Jan/2017:05:03:16 -0500
start since: 27290
accepted conn: 1107594
listen queue: 777
max listen queue: 794
listen queue len: 40000
idle processes: 0
active processes: 100
total processes: 100
max active processes: 101
max children reached: 0
slow requests: 0
재기동PHP-FPM그리고.nginx문제는 해결되지만 몇 시간 안에 다시 발생합니다.어떤 도움이라도 감사합니다.안내 좀 해주세요.
서버 설정:
DigitalOcean 48GB Memory
16 Core Processor
480GB SSD Disk
PHP-FPM 풀 설정:
pm = static
pm.max_children = 100
pm.max_requests = 5000
nginx 설정:
worker_processes 32;
worker_rlimit_nofile 100000;
events {
worker_connections 40000;
use epoll;
multi_accept on;
}
저도 쓰고 있어요.xcache,varnish와 함께W3TC워드프레스에서.(Cloudflare도 있음)
sysctl.conf:
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
### GENERAL NETWORK SECURITY OPTIONS ###
# Number of times SYNACKs for passive TCP connection.
net.ipv4.tcp_synack_retries = 2
# Allowed local port range
net.ipv4.ip_local_port_range = 2000 65535
# Protect Against TCP Time-Wait
net.ipv4.tcp_rfc1337 = 1
# Decrease the time default value for tcp_fin_timeout connection
net.ipv4.tcp_fin_timeout = 15
# Decrease the time default value for connections to keep alive
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 15
### TUNING NETWORK PERFORMANCE ###
# Default Socket Receive Buffer
net.core.rmem_default = 31457280
# Maximum Socket Receive Buffer
net.core.rmem_max = 12582912
# Default Socket Send Buffer
net.core.wmem_default = 31457280
# Maximum Socket Send Buffer
net.core.wmem_max = 12582912
# Increase number of incoming connections
net.core.somaxconn = 40000
# Increase number of incoming connections backlog
net.core.netdev_max_backlog = 65536
# Increase the maximum amount of option memory buffers
net.core.optmem_max = 25165824
# Increase the maximum total buffer-space allocatable
# This is measured in units of pages (4096 bytes)
net.ipv4.tcp_mem = 65536 131072 262144
net.ipv4.udp_mem = 65536 131072 262144
# Increase the read-buffer space allocatable
net.ipv4.tcp_rmem= 10240 87380 12582912
net.ipv4.udp_rmem_min = 16384
# Increase the write-buffer-space allocatable
net.ipv4.tcp_wmem= 10240 87380 12582912
net.ipv4.udp_wmem_min = 16384
# Increase the tcp-time-wait buckets pool size to prevent simple DOS attacks
net.ipv4.tcp_max_tw_buckets = 1440000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
NewRelic 에이전트를 중지하고 몇 시간 동안 기다린 후 문제가 해결되는지 확인하십시오.이 경우 최신 버전으로 업그레이드해 보십시오.업그레이드 후 다시 돌아오면 NewRelic 지원에 문의하십시오.
php.ini에서 max_execution_time 및 request_terminate_timeout을 확인합니다.
Nginx 설정에서도 proxy_connect_timeout, proxy_send_timeout, proxy_read_timeout 및 send_timeout 값을 확인합니다.
TCP/IP 설정을 체크하고, 킵얼라이브(keep alive) 및 타임아웃(timeout) 설정을 줄일 필요가 있는 것을 확인합니다.디스트로가 1분 이상 기본으로 제공되는 것을 본 적이 있습니다.
또, 리스너로부터의 트래픽이 유효한 트래픽인 것도 확인할 필요가 있습니다.샘플을 파일에 저장할 수 있는지 확인하고 트래픽이 합법적인지 확인합니다.많은 자동화된 프로세스가 인터웹즈에서 Wordpress 인스턴스를 찾습니다.이러한 봇은 사이트를 해킹할 때 다양한 문제를 일으킬 수 있습니다.
/var/log/nginx/에서 access.log 또는 domain.com.access.log를 확인하셨나요?PHP-FPM이 CPU를 사용하는 이유를 자세히 알 수 있습니다.
당신의 웹사이트는 wp-force에 로그인 할 수 있습니다.php, CPU가 많이 소모됩니다.
언급URL : https://stackoverflow.com/questions/41438166/site-becomes-inaccessible-due-to-php-fpm-listen-queue-cpu-touches-100
'programing' 카테고리의 다른 글
| docker-compose.yml에서 wp cli를 실행하는 방법 (0) | 2023.03.05 |
|---|---|
| ORA-12638: 자격 증명 취득 실패 (0) | 2023.03.05 |
| "런타임입니다.protractor를 실행할 때 executionContextCreated에 잘못된 '콘텍스트' 오류가 발생함 (0) | 2023.03.05 |
| Python의 json 모듈, int 사전 키를 문자열로 변환 (0) | 2023.03.05 |
| Kotlin + Jackson을 사용하여 JSON을 목록으로 역직렬화하려면 어떻게 해야 합니까? (0) | 2023.03.05 |