worker_rlimit_nofile os vs. master vs. workers

Joshua Zhu zhuzhaoyuan at gmail.com
Mon Aug 17 12:16:08 MSD 2009


Hi,

In your case, the number of connections that nginx can established is
10240 * 2 = 20480.

> Then, there is a limit I am setting in the init script for nginx.  Let's
> say this number is 20480.
>
> ulimit -n 20480
>

Basically, this is not necessary when worker_rlimit_nofile directive
is specified in your configuration file.

> Then, in the nginx config, we can set the number of workers and open
> files for each worker process.  For example:
>
> worker_processes  2;
> worker_rlimit_nofile 10240;
> ..

worker_rlimit_nofile is the maximum file descriptor number that can be
opened by one worker process:
1) If the directive is specified, nginx will set it for you
(setrlimit(1)). Default value (the ulimit -n number in your case) will
be overridden.
2) If not specified, your ulimit -n number will take effect.
3) worker_rlimit_nofile should be greater or equal to worker_connections.

> My question is, does the 20480 limit set in the init script affect:
>
> 1. the TOTAL number of files that can be open by ALL workers
> 2. the number of files that can be open by EACH worker
> 3. something else I don't understand.
>

Nope, as described above. In a word, 'ulimit -n number' is a per
process limitation.

Cheers!

-- 
Joshua Zhu





More information about the nginx mailing list