Questions regarding worker_connections

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Questions regarding worker_connections

Alder Network
Got a question regarding the worker_connections configuration. Is a worker_connection essentially
a tcp socket connection or http session? 

Via the http_stub_status_module, I can see there are
connections in waiting state, but any new request 
will result in a "worker connections are not enough" 
alert in error.log. Why it cannot accept new connections
if there are existing connections in waiting state? Is that
a bug? I am using nginx 1.6.2.

Thanks,

Alder

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Questions regarding worker_connections

Maxim Dounin
Hello!

On Fri, Aug 24, 2018 at 02:54:31PM -0700, Alder Netw wrote:

> Got a question regarding the worker_connections configuration. Is a
> worker_connection
> essentially
> a tcp socket connection or http session?

The worker_connections directive configures maximum number of
connections a worker process can open.  That is, basically this
means "TCP sockets".

See http://nginx.org/r/worker_connections for additional details.

> Via the http_stub_status_module, I can see there are
> connections in waiting state, but any new request
> will result in a "worker connections are not enough"
> alert in error.log. Why it cannot accept new connections
> if there are existing connections in waiting state? Is that
> a bug? I am using nginx 1.6.2.

Connections in the waiting state are real established connections.  
While in some cases nginx can close and re-use these connections
quickly enough to don't trigger the "worker connections are not
enough" alert, this is not something guaranteed.

In general, you should tune worker_connections so it's higher than
expected number of active connections - that is, all connections
including waiting ones.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Questions regarding worker_connections

Alder Network
Thanks Maxim for the info. So worker  connections in waiting state may not be
ready to be reused. Is there any maximum waiting time? We seem to run into
a condition that those connections are permanently stuck in waiting state.

Also, what would be the ball-park number of worker_connections  should be set 
if we want to support expected number of active connections, say 150?  
Thanks,

On Mon, Aug 27, 2018 at 4:56 AM, Maxim Dounin <[hidden email]> wrote:
Hello!

On Fri, Aug 24, 2018 at 02:54:31PM -0700, Alder Netw wrote:

> Got a question regarding the worker_connections configuration. Is a
> worker_connection
> essentially
> a tcp socket connection or http session?

The worker_connections directive configures maximum number of
connections a worker process can open.  That is, basically this
means "TCP sockets".

See http://nginx.org/r/worker_connections for additional details.

> Via the http_stub_status_module, I can see there are
> connections in waiting state, but any new request
> will result in a "worker connections are not enough"
> alert in error.log. Why it cannot accept new connections
> if there are existing connections in waiting state? Is that
> a bug? I am using nginx 1.6.2.

Connections in the waiting state are real established connections. 
While in some cases nginx can close and re-use these connections
quickly enough to don't trigger the "worker connections are not
enough" alert, this is not something guaranteed.

In general, you should tune worker_connections so it's higher than
expected number of active connections - that is, all connections
including waiting ones.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Questions regarding worker_connections

Maxim Dounin
Hello!

On Mon, Aug 27, 2018 at 10:31:13AM -0700, Alder Netw wrote:

> Thanks Maxim for the info. So worker  connections in waiting state may not
> be
> ready to be reused. Is there any maximum waiting time? We seem to run into
> a condition that those connections are permanently stuck in waiting state.

Waiting connections are connections in the keepalive state and/or
idle HTTP/2 connections.  Relevant timeouts can be tuned using the
keepalive_timeout and http2_idle_timeout directives, see docs
here:

http://nginx.org/r/keepalive_timeout
http://nginx.org/r/http2_idle_timeout

> Also, what would be the ball-park number of worker_connections  should be
> set
> if we want to support expected number of active connections, say 150?

If you are sure the number of active connections (that is, reading
+ writing + waiting) will never exceed 150, you can set
worker_connections to a similar number, adding some for various
other uses - including listening sockets and upstream connections.  
Usually 2x of the expected maximum number is a good estimate.

In the particular case of 150 active connections, it should be a
good idea to preserve "worker_connections 1024" as suggested by
the default configuration.  Simply because it hardly make sense to
use anything smaller.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx