Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Can someone explain why "ulimit" before starting Nginx?

ulimit -SHn 51200
/usr/local/webserver/nginx/sbin/nginx
share|improve this question

migrated from webmasters.stackexchange.com May 27 '11 at 5:21

This question came from our site for pro webmasters.

2 Answers 2

ulimit is a *nix command that places limits on resources. Alaz gives a good explanation that Nginx can easily exceed the default limit of 1024 file descriptors. It is necessary to raise this limit thru the ulimit command in order to have Nginx run the way you want it to.

ulimit -SHn 51200 limits the number of open file descriptors to 51200.

Here's the breakdown of your ulimit command:
-S --> use the soft resource limit
-H --> use the hard resource limit
-n --> the maximum number of open file descriptors

share|improve this answer

Nginx consumes a lot of sockets. It's a single-process web server (well, you may run several "worker" instances, but basically all of them behave like a single-process web-server) and is able to accept many connections (each of them consuming a socket) and proxy to many backends (each connections consumes a socket again). Thus, Nginx can easily excess a default limit of 1024 file descriptors per process. Which means, there is a need to increase this limit for Nginx, thus ulimit.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.