出現場景:
在用nginx做負載均衡服務器對系統做並發測試,並發量比較大時Nginx會報出Http 500錯誤
報錯原因:
訪問量大的時候,由於系統資源限制,而不能打開過多的文件
原因查找:
- 打開nginx錯誤日志(/usr/local/nginx/logs/error.log)
- 查看是否報too many open files錯誤
錯誤解決:
- 打開/etc/security/limits.conf
- 修改 limits.conf文件,加上下面兩句命令
* soft nofile 65535
* hard nofile 65535
- 打開/usr/local/nginx/conf/nginx.conf,在worker_processes的下面增加一行配置
worker_rlimit_nofile 65535;
- 重新啟動nginx,問題解決