問題描述:使用netty做性能測試時,並發過大造成Too Many open files問題
該類錯誤是因為linux系統對socket連接時需要打開的文件句柄數有限制
可以通過ulimit -a 查看
設置句柄數
ulimit -n 10000 [臨時設置]
修改 limit.conf文件
sudo vim /etc/security/limits.conf
添加
* soft nofile 10000 [soft 當超過指定數量時告警]
* hard nofile 10000 [hard 真實數值]
查看進程開啟的句柄數
lsof -n|awk '{print $2}'|uniq -c|sort -nr
統計指定端口的socket連接數
netstat -ant|grep 'port'|wc -l