Welcome! Log In Create A New Profile

Advanced

Re: Using single persistent socket to send subrequests

January 13, 2022 02:28AM
Hi,

I am trying to implement HTTP pipelining through our module. But I am unable to figure out where the source port is allocated. The only function I saw that allocates the port is: ngx_http_upstream_create_round_robin_peer. However, it doesn't get called in the path of ngx_http_run_posted_requests.

Further, ngx_http_upstream_get_round_robin_peer allocates the peer, but every time in my case the peer pointer is pointing to the same address. However, in tcpdump I always see a different source port from which the packet is sent out indicating that a new socket connection is created.

Can anyone help me understand where we get the source port from the OS and create/update the peer before sending out the packets from the socket connection?

My purpose is to reuse the same socket connection without changing the source port and use a persistent connection.

Any help is greatly appreciated.

Thanks,
Devashi
________________________________
From: nginx-devel <nginx-devel-bounces@nginx.org> on behalf of Maxim Dounin <mdounin@mdounin.ru>
Sent: Thursday, December 30, 2021 1:47 PM
To: nginx-devel@nginx.org <nginx-devel@nginx.org>
Subject: Re: Using single persistent socket to send subrequests

Hello!

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

> upstream ext-authz-upstream-server {
> server 172.20.10.6:9006;
> 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:

http://nginx.org/en/docs/http/ngx_http_upstream_module.html#max_conns
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#queue

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@nginx.org, see here:

http://nginx.org/en/support.html

Hope this helps.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

Using single persistent socket to send subrequests

dtandon 945 December 29, 2021 01:32AM

Re: Using single persistent socket to send subrequests

Maxim Dounin 284 December 29, 2021 09:38AM

Re: Using single persistent socket to send subrequests

dtandon 597 December 30, 2021 03:00AM

Re: Using single persistent socket to send subrequests

Maxim Dounin 323 December 30, 2021 03:20AM

Re: Using single persistent socket to send subrequests

dtandon 460 January 13, 2022 02:28AM

Re: Using single persistent socket to send subrequests

dtandon 568 January 28, 2022 01:16AM

Re: Using single persistent socket to send subrequests

Maxim Dounin 292 January 28, 2022 05:28PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 246
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready