Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in request distribution #7

Open
mikegagnon opened this issue Mar 13, 2012 · 1 comment
Open

Bug in request distribution #7

mikegagnon opened this issue Mar 13, 2012 · 1 comment

Comments

@mikegagnon
Copy link
Contributor

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
@gnosek
Copy link
Owner

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants