Upstream Keepalive Questions

abstein2 nginx-forum at nginx.us
Mon Apr 7 21:29:15 UTC 2014


I'm somewhat unclear about how the keepalive functionality works within the
upstream module. My nginx install currently handles several hundred domains
all of which point to different origin servers. I would imagine I can
improve performance by enabling keepalive, however the documentation says
"The connections parameter sets the maximum number of idle keepalive
connections to upstream servers that are preserved in the cache of each
worker process. When this number is exceeded, the least recently used
connections are closed. "

Does that mean that if I have 10 domains and then set keepalive to 32, that
there will potentially be up to 320 open connections from my server to the
backend servers per worker at any given point or would the worker share all
upstreams and only open a total of 32 regardless of how many upstream blocks
were on the website? Also, does the number of keepalive connections have
anything to do with the number of cores on a box?

Also, is there any downside to having a large number of upstreams in the
http block? I know for "map" block there's no performance degradation since
they're only evaluated on demand, but I don't see any kind of documentation
regarding how upstreams are handled.

Thanks!

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,249089,249089#msg-249089



More information about the nginx mailing list