Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Bug in request distribution #7

mikegagnon opened this Issue March 13, 2012 · 1 comment

2 participants

Michael N. Gagnon Grzegorz Nosek
Michael N. Gagnon

If you have a configuration like this:

upstream testing {

you would expect that upstream_fair would uniformly distribute requests to and However, if resolves to multiple IP addresses then each address for will count as a different server.

I confirmed this behavior on Ubuntu by creating two entries for localhost within /etc/hosts localhost localhost

then when you configure upstream_fair with

upstream testing {
server localhost:9000;

then the backend on 9000 receives twice as many requests as 9001

The documentation for upstream_fair does not reflect this behavior. If this behavior is intentional then it seems worthwhile to update the documentation to reflect the behavior of the module. If you want to change the behavior of the module, see the ngx_http_upstream_init_fair_rr function. In particular see lines 464 and 465

    for (i = 0; i < us->servers->nelts; i++) { // iterate over each host
        for (j = 0; j < server[i].naddrs; j++) { // iterate over each address associated with each host
Grzegorz Nosek

Patches gladly accepted :P

I'm not sure this is a bug and it could be useful for poor man's dynamic backend configuration so I'd be more inclined to merge a patch documenting this behaviour rather than ripping it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.