Achieving strong client -> upstrem_server affinity

Alexandr Gomoliako zzz at
Thu Aug 30 21:22:14 UTC 2012

> I am using ip_hash to make sure that a client will always be served by
> the same upstream server. This is essential.

> 1) Despite ip_hash being specified the request from a particular
> client IP sometimes (close to 7% of requests) get routed to a second
> upstream server

> 2) Despute proxy_next_upstream off; some requests (about 5%) are tried
> over multiple upstream servers.

> how do I go about fixing these?

With a little help from perl :)
Check out this example:
It decides which upstream to use by hashing $r->uri, but you can
replace it with $r->remote_addr

More information about the nginx mailing list