Welcome! Log In Create A New Profile

Advanced

Re: http Keepalive implementation

Maxim Dounin
June 19, 2014 09:40AM
Hello!

On Thu, Jun 19, 2014 at 01:24:53AM -0400, prkumar wrote:

> I was going through NGINX source code to implement keepalive for nginx
> zeromq plugin that I have developed.
> I have been inspired by ngx_http_upstream_keepalive_module. Was wondering
> why nginx uses a kind of two linkedlist based stack implementation to
> implement keepalive connection pool. Why not use typical linkedlist based
> queue implementation.
> Kindly refer to ngx_http_upstream_keepalive_module.c
> :ngx_http_upstream_get_keepalive_peer
> ngx_http_upstream_keepalive_module.c:ngx_http_upstream_free_keepalive_peer
>
> I used exactly like this without wondering why, now I kind of want to know
> the reason.

The upstream keepalive module uses the "cache" queue as an LRU
queue, to be able to drop unused connections if there isn't enough
room. Hence it basically uses it as a stack while storing /
retrieving connections.

The "free" queue is used to avoid runtime allocations.

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

http Keepalive implementation

prkumar June 19, 2014 01:24AM

Re: http Keepalive implementation

Maxim Dounin June 19, 2014 09:40AM

Re: http Keepalive implementation

Lord Nynex June 19, 2014 05:34PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 296
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready