consistent hashing for upstreams

Joshua Zhu zhuzhaoyuan at
Tue Mar 20 01:54:26 UTC 2012


On Tue, Mar 20, 2012 at 12:54 AM, rmalayter <nginx-forum at> wrote:

> Has anybody used ngx_http_upstream_consistent_hash with newer nginx
> releases (>1.0)?
> If so, is it possible to use ngx_http_upstream_consistent_hash with
> HTTP-based back-ends, or does it only work with memcahe backends? The
> documentation isn't at all clear.
> We want to load-balance multiple static file servers behind nginx, and
> basing the upstream chosen on consistent hash will drastically increase
> the filesystem cache hit ratios the back-end servers, while preventing a
> "thundering herd" issue when one fails. Basically you get to use all of
> your RAM amongst the back ends for cache, rather than having the same
> objects in the cache of multiple back end servers.
> I thought of trying to use map directives and regexes to pick a back
> end, but handling weighting and failover makes this a complex and
> therefore brittle approach. Could consistent hashing for upstreams be
> achieved with embedded lua or perl?
> I know HAproxy has consistent hashing features for this use case (as do
> almost all commercial load balancers), but I would prefer not adding
> layers to my stack if it can be avoided. We're already using nginx and
> proxy_cache and it has been rock-solid and stable for us.

Please try this fork:
BTW, this module will be officially supported by the Tengine team soon.


Joshua Zhu
Senior Software Engineer
Server Platforms Team at Taobao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list