Using single persistent socket to send subrequests

Maxim Dounin mdounin at
Thu Dec 30 08:17:48 UTC 2021


On Thu, Dec 30, 2021 at 07:58:33AM +0000, Devashi Tandon wrote:

>     upstream ext-authz-upstream-server {
>                 server;
>                 keepalive 4;
>     }


> However, when I create 100 simultaneous connections, they are 
> all sent via a different source port which means that a new 
> socket connection is created everytime.

That's expected behaviour: the keepalive directive specifies the 
number of connections to cache, not the limit on the number of 
connections to the upstream server.  With many simultaneous 
requests nginx will open additional connections as needed.

> How can I pipeline requests over 4 connections with keepalive 
> configuration set to 4?

You cannot, pipelining is not supported by the proxy module.

If the goal is not pipelining but to limit the number of 
connections to upstream servers, the "server ... max_conns=..." and 
the "queue" directive as available in nginx-plus might be what you 
want, see here:

Note well that such questions do not look like something related 
to nginx development.  A better mailing list for user-level 
question would be nginx at, see here:

Hope this helps.

Maxim Dounin

More information about the nginx-devel mailing list