Welcome! Log In Create A New Profile

Advanced

Re: Upstream Keepalive Questions

Maxim Dounin
April 09, 2014 07:20AM
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/

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

Upstream Keepalive Questions

abstein2 April 07, 2014 05:29PM

Re: Upstream Keepalive Questions

Maxim Dounin April 08, 2014 05:28AM

Re: Upstream Keepalive Questions

abstein2 April 08, 2014 05:41PM

Re: Upstream Keepalive Questions

Maxim Dounin April 09, 2014 07:20AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 304
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