Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Bug in request distribution #7

mikegagnon opened this Issue Mar 13, 2012 · 1 comment


None yet
2 participants

mikegagnon commented Mar 13, 2012

If you have a configuration like this:

upstream testing {
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 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

gnosek commented Apr 8, 2012

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