1

I have a python bottle app being served by nginx and uwsgi.

After running for a very few hours, I start getting a 500 error from the web app, and in /var/log/messages I see:

uwsgi: OSError: [Errno 24] Too many open files

lsof for the failing process shows 1023 files open

I've added fs.file-max=200000 to /etc/sysctl.conf

I've added to /etc/security/limit.conf:

uwsgi    soft  nofile 10000
uwsgi    hard  nofile 30000

I've done sysctl -p, and I've rebooted the machine. I still get the app failing when it hits 1,024 file descriptors.

Am I missing some uwsgi configuration, or something else? I can't seem to convince CentOS to give my app more files.

Mojo
  • 955
  • 2
  • 9
  • 24
  • is the process `uwsgi` running as user `uwsgi` ? – Phillip -Zyan K Lee- Stockmann Jan 16 '18 at 21:51
  • Yes the process is running as user uwsgi – Mojo Jan 16 '18 at 21:58
  • use sudo or similar to test if the ulimit value is set correctly: `sudo -u uwsgi -H /bin/bash` and `ulimit -n`. I also had a problem with early versions of systemd not setting configured limits correctly - that may not be the actual problem, but perhaps systemd is setting a lower limit when spawning uwsgi? – Phillip -Zyan K Lee- Stockmann Jan 16 '18 at 22:01
  • How do you start uwsgi? – Michael Hampton Jan 16 '18 at 22:01
  • uwsgi is started by systemd at boot, or `systemctl restart uwsgi` and Phillip that ulimit -n command returns 10000 – Mojo Jan 16 '18 at 22:06
  • 1
    @Michael Hampton, your question pointed me to the missing piece. I went to /usr/lib/systemd/system/uwsgi.service and added "LimitNOFILE=8192" to the [Service] block. Now cat /proc//limits shows 8192 as the open file limit. Post it as an answer and I'll give you credit. – Mojo Jan 16 '18 at 22:12
  • I understand that the answer to my question is embedded in the answer to the "duplicate" question, but a search for my problem would never turn up the "increase nproc" question, since it doesn't highlight the "Too many open files" problem. Hopefully this question about "open files" will enable people to find the answer that's in the "nproc for processes" question. I would dispute that it's "an exact duplicate." – Mojo Jan 17 '18 at 00:36

0 Answers0