JiM.am Affiliate Marketing > Misc > Optimising Nginx in Linux

Optimising Nginx in Linux

I found one of the servers was throwing up a 500 error quite regularly. I checked the logs and in /var/log/nginx/error.log I found the following errors:

socket() failed (24: Too many open files) while connecting to upstream, client
socket() failed (23: Too many open files in system) while connecting to upstream, client

Solution was to increase the number of worker connections and edit a few files to allow more open files on the file system.

// edit /etc/nginx/nginx.conf
worker_connections 8024;

//add line to /etc/sysctl.conf
fs.file-max = 120000

//add two lines to /etc/security/limits.conf
*                soft    nofile          30000
*                hard    nofile          60000

//then run:
sysctl -p

//restart nginx for good measure
/etc/init.d/nginx restart

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

More from Jim.am
The truth about online advertising agencies and consultants
7 easy ways to make money with affiliate marketing
How to choose offers from an affiliate network
11 Proven Headline Formulas For Affiliate Marketing
Automatic Redirect for Mobile Landing Page
Leading Ad Networks
Dynamic Tokens For Major Ad Networks
Checking landing page load times
Setting Up Retargeting Pixels for Adwords and Facebook
Fastlane Millionaire - BoM May
Golden Gems in Copywriting
SEO for Fun and Profit
The intelligent investor - April's Book of the Month
The balance of an online marketers skillset
Big list of mobile carriers by country

Code | CPA | Creative | Design | Display | Misc | Mobile | News | PPC | PPV | SEO | Social | Tracking | Traffic | Travels | Tutorials |