# Upstream load balancing

**URL:** <https://www.ruby-forum.com/t/upstream-load-balancing/227935>\
**Category:** NGINX\
**Created:** [April 3, 2013, 10:19pm UTC](https://www.ruby-forum.com/t/upstream-load-balancing/227935 "2013-04-03T22:19:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![steveybaby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c57346/32.png) [@steveybaby](https://www.ruby-forum.com/u/steveybaby)\
**Post date:** [April 3, 2013, 10:19pm UTC](https://www.ruby-forum.com/t/upstream-load-balancing/227935/1 "2013-04-03T22:19:53Z")

</div>

Folks,

I’m sharing processing load across 3 remote servers, and am having a  
terrible time getting it balanced.

Here’s the config

upstream backend {  
server 192.168.162.218:9000 fail\_timeout=30 max\_fails=3 weight=1  
; # Engine 1  
server 192.168.175.5:9000 fail\_timeout=30 max\_fails=3 weight=1;

# Engine 2

```
server 192.168.175.213:9000 fail_timeout=30 max_fails=3 weight=1

```

; # Engine 3  
}

When the server gets busy, all load seems to be put onto the final  
entry, which is seeing load averages in the 70’s, whereas the first 2  
are below 5.

This is causing serious performance issues. How on earth can we force a  
more even loading?

Cheers,

Steve

---

<div class="post-metadata">

**Author:** ![steveybaby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c57346/32.png) [@steveybaby](https://www.ruby-forum.com/u/steveybaby)\
**Post date:** [April 4, 2013, 4:15pm UTC](https://www.ruby-forum.com/t/upstream-load-balancing/227935/2 "2013-04-04T16:15:41Z")

</div>

Hello!

On Thu, Apr 04, 2013 at 09:18:53AM +1300, Steve H. wrote:

> ```
> server 192.168.175.5:9000 fail_timeout=30 max_fails=3 weight=1;
> 
> ```
> 
> This is causing serious performance issues. How on earth can we force a  
> more even loading?

The above configuration should result in equal number of requests  
to each of the backends. This may not be the same as equal load  
in terms of load averages, especially if servers are not equal.  
You may use “weight=” parameter to tune request distribution more  
precisely.

Alternatively, you may consider using least\_conn balancer  
algorithm for atomatic balancing based on number of currently  
active connections to upstream servers configured. See  
[Module ngx\_http\_upstream\_module](http://nginx.org/r/least_conn) for details.

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**
