# Nginx upstream not balancing properly

**URL:** <https://www.ruby-forum.com/t/nginx-upstream-not-balancing-properly/223592>\
**Category:** NGINX\
**Created:** [October 10, 2012, 4:50pm UTC](https://www.ruby-forum.com/t/nginx-upstream-not-balancing-properly/223592 "2012-10-10T16:50:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [October 10, 2012, 4:50pm UTC](https://www.ruby-forum.com/t/nginx-upstream-not-balancing-properly/223592/1 "2012-10-10T16:50:57Z")

</div>

Hi,

I am running latest nginx and using it for load balancing. I am using  
the  
upstream fair module.

I have 3 backend servers running apache. The problem is that when I  
start a  
load test the balancing is not done correctly. The first server in the  
upstream gets most of the traffic and the other 2 get very few traffic.  
If I  
restart nginx then all 3 backend servers start to get the same ammount  
of  
traffic

Am I doing something wrong?

Please advise

Posted at Nginx Forum:

> **[nginx upstream not balancing properly](https://forum.nginx.org/read.php?2,231585,231585#msg-231585)**
>
> Hi, I am running latest nginx and using it for load balancing. I am using the upstream fair module. I have 3 backend servers running apache. The problem is that when I start a load test the balancing is not done correctly. The first server in the...

---

<div class="post-metadata">

**Author:** ![izghitu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/cc9497/32.png) [@izghitu](https://www.ruby-forum.com/u/izghitu)\
**Post date:** [October 10, 2012, 5:02pm UTC](https://www.ruby-forum.com/t/nginx-upstream-not-balancing-properly/223592/2 "2012-10-10T17:02:04Z")

</div>

On Oct 10, 2012, at 6:50 PM, izghitu wrote:

> Am I doing something wrong?
> 
> Please advise

First of all, do you mean our standard least\_conn functionality or some  
3rd party module?

> **[Module ngx\_http\_upstream\_module](http://nginx.org/en/docs/http/ngx_http_upstream_module.html#least_conn)**
>
> The ngx\_http\_upstream\_module module is used to define groups of servers that can be referenced by the proxy\_pass, fastcgi\_pass, uwsgi\_pass, scgi\_pass, memcached\_pass, and grpc\_pass directives.

---

<div class="post-metadata">

**Author:** ![izghitu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/cc9497/32.png) [@izghitu](https://www.ruby-forum.com/u/izghitu)\
**Post date:** [October 10, 2012, 5:35pm UTC](https://www.ruby-forum.com/t/nginx-upstream-not-balancing-properly/223592/3 "2012-10-10T17:35:57Z")

</div>

On Oct 10, 2012, at 7:24 PM, izghitu wrote:

> Hi,
> 
> This is what I am using  
> [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/HttpUpstreamFairModule)

Can you try your setup with

> **[Module ngx\_http\_upstream\_module](http://nginx.org/en/docs/http/ngx_http_upstream_module.html#least_conn)**
>
> The ngx\_http\_upstream\_module module is used to define groups of servers that can be referenced by the proxy\_pass, fastcgi\_pass, uwsgi\_pass, scgi\_pass, memcached\_pass, and grpc\_pass directives.

which is part of standard distributions since 1.3.1 and 1.2.2-stable?

---

<div class="post-metadata">

**Author:** ![izghitu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/cc9497/32.png) [@izghitu](https://www.ruby-forum.com/u/izghitu)\
**Post date:** [October 10, 2012, 5:25pm UTC](https://www.ruby-forum.com/t/nginx-upstream-not-balancing-properly/223592/4 "2012-10-10T17:25:26Z")

</div>

Hi,

This is what I am using

> **[Upstream Fair Balancer | NGINX](https://www.nginx.com/resources/wiki/modules/fair_balancer/)**
>
> The Upstream Fair Balancer module distributes incoming requests to the least busy backend servers, rather than using a round-robin algorithm.

Posted at Nginx Forum:

> **[Re: nginx upstream not balancing properly](https://forum.nginx.org/read.php?2,231585,231587#msg-231587)**
>
> Hi, I am running latest nginx and using it for load balancing. I am using the upstream fair module. I have 3 backend servers running apache. The problem is that when I start a load test the balancing is not done correctly. The first server in the...

---

<div class="post-metadata">

**Author:** ![izghitu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/cc9497/32.png) [@izghitu](https://www.ruby-forum.com/u/izghitu)\
**Post date:** [October 10, 2012, 5:42pm UTC](https://www.ruby-forum.com/t/nginx-upstream-not-balancing-properly/223592/5 "2012-10-10T17:42:59Z")

</div>

Thanks for your input. I will test with that one and let you know how it  
goes

Posted at Nginx Forum:

> **[Re: nginx upstream not balancing properly](https://forum.nginx.org/read.php?2,231585,231591#msg-231591)**
>
> Hi, I am running latest nginx and using it for load balancing. I am using the upstream fair module. I have 3 backend servers running apache. The problem is that when I start a load test the balancing is not done correctly. The first server in the...
