Forum: NGINX max_clients and keep alive

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Tristan Griffiths (Guest)
on 2009-05-18 04:03
(Received via mailing list)
Hello,

Trying to better understand the worker_processes and worker_connections
settings.

We have always run Nginx with worker_processes 4 and worker_connections
1024 on a dual Xeon 2.4GHz with Hyper Threading. In the documentation,
it suggests it is better to run worker_processes 2 and
worker_cpu_affinity 0101 1010 for a dual HTT machine but according to
the formula (max_clients = worker_processes * worker_connections) that
would effectively halve the connections we can support to clients and
backend servers.

We regularly see more than 2000 keep alive connections at any point in
time, so do keep alive connections count towards the maximum client
connections?

Thanks,

Tristan
Maxim D. (Guest)
on 2009-05-18 15:16
(Received via mailing list)
Hello!

On Mon, May 18, 2009 at 09:54:34AM +1000, Tristan Griffiths wrote:

> would effectively halve the connections we can support to clients and
> backend servers.
>
> We regularly see more than 2000 keep alive connections at any point in
> time, so do keep alive connections count towards the maximum client
> connections?

Yes.

Feel free to increase worker_connections.  Note also that worker
connections are cheap - they consume only about 200 bytes of
memory per connection, so setting something like 16384 isn't a
big deal.

The only thing to keep in mind is that your OS settings should be
tuned as well or this may lead to bad results.  E.g. make sure
that worker_connections are less than available to nginx process
number of file descriptors (kern.maxfilesperproc under FreeBSD).

Maxim D.
Tristan Griffiths (Guest)
on 2009-05-19 04:00
(Received via mailing list)
> -----Original Message-----
> From: removed_email_address@domain.invalid [mailto:removed_email_address@domain.invalid] 
On Behalf
Of
> >
> > Trying to better understand the worker_processes and
> worker_connections
> > settings.
> >
> > We have always run Nginx with worker_processes 4 and
> worker_connections
> > 1024 on a dual Xeon 2.4GHz with Hyper Threading. In the
> documentation,
> > it suggests it is better to run worker_processes 2 and
> > worker_cpu_affinity 0101 1010 for a dual HTT machine but according
to
> > the formula (max_clients = worker_processes * worker_connections)
> that
> > would effectively halve the connections we can support to clients
and
> connections are cheap - they consume only about 200 bytes of
> memory per connection, so setting something like 16384 isn't a
> big deal.
>
> The only thing to keep in mind is that your OS settings should be
> tuned as well or this may lead to bad results.  E.g. make sure
> that worker_connections are less than available to nginx process
> number of file descriptors (kern.maxfilesperproc under FreeBSD).
>
> Maxim D.

CentOS 5.3 kernel-PAE

[root@lb1 ~]# sysctl fs.file-max
fs.file-max = 400136

And that's the default setting!

Thank you for your help Maxim.
Arvind Jayaprakash (Guest)
on 2009-06-10 21:39
(Received via mailing list)
On May 18, Maxim D. wrote:
>> 1024 on a dual Xeon 2.4GHz with Hyper Threading. In the documentation,
>Yes.
>
>Feel free to increase worker_connections.  Note also that worker
>connections are cheap - they consume only about 200 bytes of
>memory per connection, so setting something like 16384 isn't a
>big deal.
>
>The only thing to keep in mind is that your OS settings should be
>tuned as well or this may lead to bad results.  E.g. make sure
>that worker_connections are less than available to nginx process
>number of file descriptors (kern.maxfilesperproc under FreeBSD).

If the master process starts as root and worker_rlimit_nofile is set,
then does any of system limit wrt fd matter?
Maxim D. (Guest)
on 2009-06-11 01:19
(Received via mailing list)
Hello!

On Wed, Jun 10, 2009 at 11:01:30PM +0530, Arvind Jayaprakash wrote:

[...]

> If the master process starts as root and worker_rlimit_nofile is set,
> then does any of system limit wrt fd matter?

Yes, they does matter.  Via setrlimit() you may not set limits
greater than kernel ones (like kern.maxfilesperproc,
kern.maxfiles under FreeBSD).

On the other hand, worker_rlimit_nofile usually required only when
you expanded kernel limits and want running nginx to expand it's
limits without restarting master (as rlimits usally defaults to
kernel limits at the time of process creation).

Maxim D.
This topic is locked and can not be replied to.