<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hi,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
We have the following configuration:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
location / {
<div> proxy_http_version 1.1;</div>
<div><span style="color: rgb(0, 0, 0);"> proxy_pass </span><span style="color: rgb(0, 0, 0);"> </span><a href="http://ext-authz-upstream-server" id="LPlnk261798"><span style="color:rgb(0,0,0)">http://ext-authz-upstream-server</span></a><span style="color: rgb(0, 0, 0);">;</span><br>
</div>
}<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
upstream ext-authz-upstream-server {
<div> server 172.20.10.6:9006;</div>
<div> keepalive 4;</div>
}<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
With this configuration, as per the previous email in nginx-devel, I am expecting that when I
<b>sequentially</b> send 5 requests the 5<span><sup>th</sup> request should reuse one of the ports of the first four requests since 4 socket connections should be cached and persistent. But I observe that the 5<span><sup>th</sup> connection is also sent from
a new source port. </span></span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span><span><br>
</span></span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span><span><br>
</span></span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span><span>Do I need to add any other configuration to reuse the first four socket connections besides keepalive 4?</span></span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span><br>
</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span>Looking forward to your response.</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span><br>
</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span>Thanks,</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span>Devashi </span></div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> nginx-devel <nginx-devel-bounces@nginx.org> on behalf of Maxim Dounin <mdounin@mdounin.ru><br>
<b>Sent:</b> Thursday, December 30, 2021 1:47 PM<br>
<b>To:</b> nginx-devel@nginx.org <nginx-devel@nginx.org><br>
<b>Subject:</b> Re: Using single persistent socket to send subrequests</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">Hello!<br>
<br>
On Thu, Dec 30, 2021 at 07:58:33AM +0000, Devashi Tandon wrote:<br>
<br>
> upstream ext-authz-upstream-server {<br>
> server 172.20.10.6:9006;<br>
> keepalive 4;<br>
> }<br>
<br>
[...]<br>
<br>
> However, when I create 100 simultaneous connections, they are <br>
> all sent via a different source port which means that a new <br>
> socket connection is created everytime.<br>
<br>
That's expected behaviour: the keepalive directive specifies the <br>
number of connections to cache, not the limit on the number of <br>
connections to the upstream server. With many simultaneous <br>
requests nginx will open additional connections as needed.<br>
<br>
> How can I pipeline requests over 4 connections with keepalive <br>
> configuration set to 4?<br>
<br>
You cannot, pipelining is not supported by the proxy module.<br>
<br>
If the goal is not pipelining but to limit the number of <br>
connections to upstream servers, the "server ... max_conns=..." and <br>
the "queue" directive as available in nginx-plus might be what you <br>
want, see here:<br>
<br>
<a href="http://nginx.org/en/docs/http/ngx_http_upstream_module.html#max_conns">http://nginx.org/en/docs/http/ngx_http_upstream_module.html#max_conns</a><br>
<a href="http://nginx.org/en/docs/http/ngx_http_upstream_module.html#queue">http://nginx.org/en/docs/http/ngx_http_upstream_module.html#queue</a><br>
<br>
Note well that such questions do not look like something related <br>
to nginx development. A better mailing list for user-level <br>
question would be nginx@nginx.org, see here:<br>
<br>
<a href="http://nginx.org/en/support.html">http://nginx.org/en/support.html</a><br>
<br>
Hope this helps.<br>
<br>
-- <br>
Maxim Dounin<br>
<a href="http://mdounin.ru/">http://mdounin.ru/</a><br>
_______________________________________________<br>
nginx-devel mailing list<br>
nginx-devel@nginx.org<br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br>
</div>
</span></font></div>
</body>
</html>