http Keepalive implementation
mdounin at mdounin.ru
Thu Jun 19 13:38:06 UTC 2014
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
> 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 /
The "free" queue is used to avoid runtime allocations.
More information about the nginx