刚才测试了一下nginx并发链接数,在同时在线人数为 2000的时候,不能访问网页,出现500 Internal Server Error,查看了一下日志/var/log/nginx/error.log
[root@lxadmin nginx]# tail -n 30 error.log
2008/11/06 21:19:46 [alert] 1110#0: accept() failed (24: Too many open files) while accepting new connection on 0.0.0.0:80
2008/11/06 21:19:46 [alert] 1110#0: accept() failed (24: Too many open files) while accepting new connection on 0.0.0.0:80
2008/11/06 21:19:46 [alert] 1110#0: accept() failed (24: Too many open files) while accepting new connection on 0.0.0.0:80
2008/11/06 21:19:46 [alert] 1110#0: accept() failed (24: Too many open files) while accepting new connection on 0.0.0.0:80
2008/11/06 21:19:46 [alert] 1110#0: accept() failed (24: Too many open files) while accepting new connection on 0.0.0.0:80
2008/11/06 21:19:46 [alert] 1110#0: accept() failed (24: Too many open files) while accepting new connection on 0.0.0.0:80
2008/11/06 21:19:46 [alert] 1110#0: accept() failed (24: Too many open files) while accepting new connection on 0.0.0.0:80
看来是模拟的并发数太多了,需要调整一下nginx.conf的并发设置数,(我的配置主机的内存 128M,CPU为1G,)
vi /etc/nginx/nginx.conf
events {
worker_connections 1024;
}
调整为
events {
worker_connections 10240;
}
还是会出现上面问题,使用
[root@lxadmin nginx]# cat /proc/sys/fs/file-max
8192
文件系统最大可打开文件数
[root@lxadmin nginx]# ulimit -n
1024
程序限制只能打开1024个文件
使用[root@lxadmin nginx]# ulimit -n 8192调整一下
或者永久调整打开文件数 可在启动文件/etc/rc.d/rc.local末尾添加(在/etc/sysctl.conf末尾添加fs.file-max=xxx无效)
ulimit -n 8192
没有评论 :
发表评论