nginx worker process hang,cpu load very high

ovear nginx-forum at nginx.us
Tue Aug 28 07:12:52 UTC 2012


Hi,
I have faced a trouble with nginx runs as a http revers proxy server,if you
download a big file(like mp3,rar file),that nginx worker process will take
lots of cpu, that process will hang, and wait a few minutes (about 3 - 8
minutes),it will be normal,but if you wait for a long time,it will happen
again.

[root at ovear ~]# lsb_release -a
LSB Version:
:core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.8 (Final)
Release: 5.8
Codename: Final
[root at ovear ~]# uname -a
Linux ovear 2.6.18-308.el5 #1 SMP Tue Feb 21 20:06:06 EST 2012 x86_64 x86_64
x86_64 GNU/Linux

nginx version
[root at ovear ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/0.8.55
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-52)
TLS SNI support disabled
configure arguments: --user=nobody --group=nobody
--add-module=../ngx_cache_purge-1.5 --with-http_stub_status_module
--with-http_ssl_module --with-http_realip_module
[root at ovear ~]#
(also tested under 1.x,have the same problem)

nginx config
worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000;




events {
use epoll;
worker_connections 51200;
}


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 50m;

sendfile on;
tcp_nopush on;

keepalive_timeout 60;

tcp_nodelay on;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$host"';

server {
listen 9998;
server_name _;

location /
{
proxy_pass http://116.255.1.1;
include proxy.conf;
}

location ~ ^/status {
stub_status on;
access_log off;
}


}
}


realip.conf
set $my_x_real_ip "";
if ($http_x_real_ip ~ "^$") {
set $my_x_real_ip $remote_addr;
}
if ($my_x_real_ip ~ "^$") {
set $my_x_real_ip $http_x_real_ip;
}


proxy.conf

include realip.conf;
proxy_connect_timeout 30s;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 32k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_redirect off;
proxy_hide_header Vary;
proxy_set_header Accept-Encoding '';
proxy_set_header Host $host;
proxy_set_header Referer $http_referer;
proxy_set_header Cookie $http_cookie;
proxy_set_header X-Real-IP $my_x_real_ip;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


trouble
[root at ovear conf]# ps aux|grep -e CPU -e nginx
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 17826 0.0 0.0 41168 1060 ? Ss 23:16 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
nobody 17827 2.1 0.5 60380 20436 ? S 23:16 0:00 nginx: worker process
nobody 17828 1.5 0.5 60380 20436 ? S 23:16 0:00 nginx: worker process
nobody 17829 23.6 0.5 63036 23444 ? S 23:16 0:04 nginx: worker process
nobody 17830 3.0 0.5 60380 20724 ? S 23:16 0:00 nginx: worker process
root 17851 0.0 0.0 61168 812 pts/1 S+ 23:16 0:00 grep -e CPU -e nginx
[root at ovear conf]#

nginx pid 17829 are hanging,there are nothing in error.log

thanks

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,230177,230177#msg-230177



More information about the nginx mailing list