Nginx load-balance set weight and ip_hash at the same time

load balancingnginx

By default the Nginx upstream directive uses Round-Robin to distribute requests to backend realsevers and set the weight of the server by weight. But I do not see any words about whether weight works for ip_hash too.

Some people say weight does not work with ip_hash, but I've seen examples of this in too many blogs articles to name.

Questions

  • And what about nginx-sticky-module?
  • Distribute requests strictly with cookie-sticky and ignore weight, or weight DO work for the first time Nginx handles the client's request?

Best Answer

From http://nginx.org/en/docs/http/load_balancing.html

It is similarly possible to use weights with the least-connected and ip-hash load balancing in the recent versions of nginx.

However, with 1.8 it does not work well for me, at least not when user accesses different domains over the same upstream.