Reputation: 1
I'm a newbie to nginx load balancing but i got it setup according to the documentation and from some samples online.
Here's how i setup my upstream config:
upstream test {
server FirstServerIP weight=1 max_fails=3 fail_timeout=15s;
server SecondServerIP weight=1 max_fails=3 fail_timeout=15s;
}
Then i enter in:
proxy_pass http://test;
Into the location part of config. For the backend i'm using port 8181 of the "FirstServerIP" to proxy into port 80 of the first and second server. Everything is fine until i check my bandwidth usage of my FirstServerIP and find that the incoming traffic is triple my SecondServerIP and the outgoing traffic is around the same as my SecondServerIP...
Can you tell me why? and how i could fix it? Cause it seem like the data is being uploaded to my FirstServer from my SecondServer and then sent back to the user.
Upvotes: 0
Views: 997
Reputation: 182769
It sounds like the configuration is doing exactly what you asked it to do. You configured a proxy on the first server IP, right? So data has to go from the user to the proxy, then to the server, then the reply from the server back to the proxy and then to the user.
It's triple because the first server sees three flows (both servers' output from the proxy and the second server's input to the proxy) while the second server sees one (its output to the proxy). It is perfectly balancing the traffic into equal flows, the first server just sees three flows and the second just one.
As for how you fix it, it depends what's wrong with it and what you're trying to accomplish, which you haven't told us.
Upvotes: 1