P
P
Puma Thailand2017-03-08 11:28:30
go
Puma Thailand, 2017-03-08 11:28:30

How to increase the limits of open files (sockets) for a go program?

The following errors are thrown in the go log
2017/03/08 08:11:11 http: Accept error: accept tcp [::]:9001: accept4: too many open files; retrying in 5ms
2017/03/08 08:11:11 http: Accept error: accept tcp [::]:9001: accept4: too many open files; retrying in 10ms
Actually in limits.conf
* soft nproc 200000
* hard nproc 200000
* soft nofile 200000
* hard nofile 200000
ulimit -n
200000
in sysctl.conf
fs.file-max = 99999999
but when I look at the limits on the app itself for some reason there is 1024 soft and 4048 hard
cat /proc/26602/limits
Limit Soft Limit Hard Limit Units
Max open files 1024 4096 files
How to increase the application limit?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Puma Thailand, 2017-03-10
@opium

As a result, it turned out that this is a default restriction that is imposed by systemd
In the service startup script, you need to prescribe
LimitNOFILE=200000
LimitNPROC=200000

M
Michael, 2017-03-09
@Singaporian

But this is a crutch solution. How much can limits be increased? Isn't it more correct to figure out why there are so many open descriptors at the same time?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question