hb-chen/echo-web

echo: http: Accept error: accept tcp [::]:8080: accept4: too many open files; retrying in 1s

Closed this issue · 1 comments

echo: http: Accept error: accept tcp [::]:8080: accept4: too many open files; retrying in 20ms
echo: http: Accept error: accept tcp [::]:8080: accept4: too many open files; retrying in 40ms
echo: http: Accept error: accept tcp [::]:8080: accept4: too many open files; retrying in 80ms
echo: http: Accept error: accept tcp [::]:8080: accept4: too many open files; retrying in 160ms
echo: http: Accept error: accept tcp [::]:8080: accept4: too many open files; retrying in 320ms
echo: http: Accept error: accept tcp [::]:8080: accept4: too many open files; retrying in 640ms
echo: http: Accept error: accept tcp [::]:8080: accept4: too many open files; retrying in 1s

查看运行进程的limit信息

$ ps -ax | grep echo-web
 4038 ?        Sl     0:00 /echo-web -c /conf/conf.toml

$ cat /proc/6825/limits
Limit                     Soft Limit           Hard Limit           Units
……
Max open files            1024                 4096                 files
……

其中Max open files为1024太低,需要提升

  1. Supervisord守护进程运行的,需要修改Supervisord配置
    supervisord
$ vi /etc/supervisor/supervisord.conf
[supervisord]
minfds = 10240
  1. Shell直接运行的,可以通过ulimit提升配置
$ ulimit -n 10240

更多关于open file限制可以了解

  • /etc/sysctl.conf
    • fs.file-max = 6553560
  • /etc/security/limits.conf
      • soft nofile 65535
      • hard nofile 65535