"too many open files" message in the logs (solved)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

"too many open files" message in the logs (solved)

Carlos Oliva
Hi list:

I had a problem last days and I want to share with you how to solve it, just in case somebody has the same problem in the future. Devels, maybe is a good thing to publish in troubleshoting page.

I started to see in a Opensips 1.11.9 log tons of messages with this text:

ERROR:core:handle_new_connect: failed to accept connection(24): Too many open files

This is a TLS enabled proxy, the vast majority of clients connect to it using TLS protocol, and the AORs population is about 1000 users.

I thought about kernel FD limits, but checking generic kernel limits seems the value is too high.

You can check the open files used by opensips TCP main process using something like "ls -la /proc/PID/fd | wc -l" and check the limit for a specific process using "cat /proc/PID/limits"

Checking the specific limits of the TCP main process, I can see the limit for "max open files" is 1024 how is this possible?

The reason is I'm using systemd to launch Opensips, and systemd completely ignores global kernel limits.

The solution is to put the limit in systemd init file, something like this inside [service] section:
LimitNOFILE=49152

This is my complete systemd init file, if somebody find it useful.


[Unit]
Description=Opensips Sip server
After=network.target
After=mediaproxy-dispatcher.service

[Service]
Type=forking
TimeoutSec=10s
LimitNOFILE=49152
PIDFile=/var/run/opensips/opensips.pid
ExecStartPre=/bin/mkdir -p /var/run/opensips
ExecStartPre=/bin/chmod 775 /var/run/opensips
ExecStartPre=/bin/chown opensips.opensips /var/run/opensips
ExecStartPre=/usr/sbin/opensips -c
ExecStart=/usr/sbin/opensips -P /var/run/opensips/opensips.pid -m 192 -M 16 -u opensips -g opensips
Restart=always



[Install]
WantedBy=multi-user.target

Later do a systemctl daemon-reload and restart opensips service. The new limits are applied now.

Hope this can help somebody with my problem in the future.

Regards,

Carlos Oliva
   





_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users