On Wed, Dec 29, 2021 at 06:30:11AM +0000, Devashi Tandon wrote:
> We have a auth module in our code that sends requests to a
> server and waits for response to approve the request before
> proceeding to forward the request to a proxy server.
> We use the function ngx_http_post_request to post the
> As I understand, this function adds the request to a queue which
> is then processed by ngx_http_run_posted_requests function.
> We observe that every single subrequest is sent over a new
> socket connection. Unfortunately, when we scale to more than
> 1000 concurrent subrequests, we start seeing socket failures.
> Is there a way to specify to this function, to maintain a
> persistent socket connection with the auth server and reuse the
> same socket connection for sending multiple subrequests?
In no particular order:
- Using ngx_http_post_request() directly might not be a good idea.
Consider using ngx_http_subrequest() instead.
- For the particular task there is the auth_request module
It might be a good idea to use it instead of rolling your own
- Every subrequest is processed according to the configuration
specified in the configuration file, much like any other
request. To use persistent connections to upstream servers you
have to configure nginx to do so as usual, see
Hope this helps.
nginx-devel mailing list