load balancing algorithms
mdounin at mdounin.ru
Tue Sep 26 15:07:08 UTC 2017
On Tue, Sep 26, 2017 at 09:43:37AM -0400, Adam Schwartz wrote:
> > On the other hand, there is API in nginx which allows to implement
> > any load balancing algorithm needed.
> Cool! I was looking for something like that.
> > As for the algorithms you've mentioned, "power of two choices" seems
> > to be better than random, though it does not look like it is
> > beneficial even compared to round-robin.
> Are there specific reasons or example you have that show round-robin is sufficient?
As long as we are assuming single load balancer and identical
requests, round-robin essentially means that we place equal load
on all balanced servers, and this is better than what "power of
two choices" can provide. Certainly things will be different if
requests are not equal, though this is what least_conn is expected
to address (and again, it does so better than just testing two
As far as I understand, "Power of two choices" might be beneficial
if you need to optimize time spent on comparing the load on
different balanced servers, for example, when balancing very large
number of servers. Or when trying to do distributed balancing
with multiple load balancers, and query loads directly from
balanced servers - but this is not something nginx currently tries
More information about the nginx