# Nginx upstream fair

**URL:** <https://www.ruby-forum.com/t/nginx-upstream-fair/184933>\
**Category:** NGINX\
**Created:** [March 10, 2010, 4:06pm UTC](https://www.ruby-forum.com/t/nginx-upstream-fair/184933 "2010-03-10T16:06:17Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [March 10, 2010, 4:06pm UTC](https://www.ruby-forum.com/t/nginx-upstream-fair/184933/1 "2010-03-10T16:06:17Z")

</div>

Hi,

I have latest nginx on a 64bit CentOS running.

I use it as a load balancer in front of 2 apache servers.

The upstream config is the following:  
upstream name {  
fair;  
server apache1;  
server apache2;  
}

server {  
listen nginx:80;  
location / {  
proxy\_set\_header Host $host;  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;  
proxy\_pass [http://name](http://name);  
}  
}

My problem is that the server that I put at the bottom in the upstream  
conf gets a lot less connections then the server that is first. When  
load testing and sending lots of connections to the nginx server I can  
see from the nginx error\_log that the connections to apache1 time out  
but it still tries to send new ones to it while the apache2 server has  
few connections with nginx and gets few new connections.

If I change the order in the upstream then the problem still persists  
but with the other server.

Am I doing something wrong?

Please help.

Posted at Nginx Forum:

> **[nginx upstream fair](https://forum.nginx.org/read.php?2,62274,62274#msg-62274)**
>
> Hi, I have latest nginx on a 64bit CentOS running. I use it as a load balancer in front of 2 apache servers. The upstream config is the following: upstream name { fair; server apache1; server apache2; }

---

<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:** [March 11, 2010, 12:50pm UTC](https://www.ruby-forum.com/t/nginx-upstream-fair/184933/2 "2010-03-11T12:50:38Z")

</div>

On Å›ro, mar 10, 2010 at 10:05:40 -0500, izghitu wrote:

> ```
> server apache2;
> 
> ```
> 
> }
> 
> My problem is that the server that I put at the bottom in the upstream conf gets a lot less connections then the server that is first. When load testing and sending lots of connections to the nginx server I can see from the nginx error\_log that the connections to apache1 time out but it still tries to send new ones to it while the apache2 server has few connections with nginx and gets few new connections.
> 
> If I change the order in the upstream then the problem still persists but with the other server.
> 
> Am I doing something wrong?
> 
> Please help.

Will try to reproduce it and get back to you. What kind of load are you  
testing it with (approximate req/sec, reply size)?

upstream-fair does have a mode of operation which disables round-robin  
behaviour but you’re not using it here so it does look like a bug.

Best regards,  
Grzegorz N.

---

<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:** [April 13, 2010, 10:50pm UTC](https://www.ruby-forum.com/t/nginx-upstream-fair/184933/3 "2010-04-13T22:50:33Z")

</div>

Hi,

Sorry for the delay in replying.

I am using very high load. Like 500+ clients simultaneously hitting  
nginx at the same time.

I have another thread with more details and problems opened here:

> **[nginx upstream problem](https://forum.nginx.org/read.php?2,74663)**
>
> Hi, I have several problems when using nginx as a load balancer. Nginx 0.8.35 CentOS 5.4 64bit Kernel 2.6.28.10 Configs: /etc/nginx/nginx.conf \[code\] user nobody; worker\_processes 32; worker\_rlimit\_nofile

Thanks

Posted at Nginx Forum:

> **[Re: nginx upstream fair](https://forum.nginx.org/read.php?2,62274,74676#msg-74676)**
>
> Hi, I have latest nginx on a 64bit CentOS running. I use it as a load balancer in front of 2 apache servers. The upstream config is the following: upstream name { fair; server apache1; server apache2; }
