Fixing nginx "Too many open files" errors post

Posted on 2014-11-27 by jwage

At OpenSky, we recently migrated to the InstartLogic CDN. One of the features they provide is the ability to resize images by appending ?iresize=width:500,height:500 to your image URLs.

This feature allowed us to start serving static files directly through nginx instead of going through our application to generate the requested size. Now, InstartLogic does all the resizing work for us and our backend PHP servers are relieved of this responsibility.

This was a nice win for us but it introduced a slight new problem. Nginx started complaining about “Too many open files”. This was easily fixed for us by setting the worker_rlimit_nofile setting in the nginx.conf file to 30000.

worker_rlimit_nofile 30000;

After this change our backend PHP servers have a lighter load and the first request for an image through the CDN is much faster.