Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Bug in request distribution #7

Open
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 {
fair;
server foo.com:9000;
server bar.com:9000;
}

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

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

127.0.0.1 localhost
127.0.0.1 localhost

then when you configure upstream_fair with

upstream testing {
fair;
server localhost:9000;
server 127.0.0.1:9001;
}

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
Owner

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.