Upstream Keepalive Questions
Maxim Dounin
mdounin at mdounin.ru
Wed Apr 9 11:18:04 UTC 2014
Hello!
On Tue, Apr 08, 2014 at 05:41:17PM -0400, abstein2 wrote:
> Maxim,
>
> Thanks so much for clarifying. Just to make sure I'm understanding
> correctly, if I had something like this pseudo-code
>
> upstream upstream1 { }
> upstream upstream2 { }
> upstream upstream3 { }
> upstream upstream4 { }
> upstream upstream5 { }
>
> server { server_name server1.com; proxy_pass http://upstream1; }
> server { server_name server2.com; proxy_pass http://upstream2; }
> server { server_name server3.com; proxy_pass http://upstream3; }
> server { server_name server4.com; proxy_pass http://upstream4; }
> server { server_name server5.com; proxy_pass http://upstream5; }
>
> There would only be performance degradation if the setup was:
>
> server {
> server_name server6.com;
> set $PROXY_TO 'upstream5';
> proxy_pass http://$PROXY_TO;
> }
>
> Is that correct?
Yes. The "degradation" is due to upstream{} blocks are in stored
an array, and looking up an upstream uses linear array traversal.
That is, cost of looking an upstream sever in the "proxy_pass
http://$proxy_to" is O(n), where n - number of upstream{} blocks
in the configuration.
I don't think the difference will be measurable even with
thousands of upstream{} blocks though.
> And, if there was degradation, would it be limited to hosts
> that server block was trying to serve or would it impact overall
> performance?
See above, it is only related to upstream{} block lookup in
"proxy_pass http://$proxy_to" and doesn't affect requests where
this proxy_pass isn't used.
--
Maxim Dounin
http://nginx.org/
More information about the nginx
mailing list