# 50% of Failed requests with load balance

**URL:** <https://www.ruby-forum.com/t/50-of-failed-requests-with-load-balance/198913>\
**Category:** NGINX\
**Created:** [November 10, 2010, 3:57pm UTC](https://www.ruby-forum.com/t/50-of-failed-requests-with-load-balance/198913 "2010-11-10T15:57:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 10, 2010, 3:57pm UTC](https://www.ruby-forum.com/t/50-of-failed-requests-with-load-balance/198913/1 "2010-11-10T15:57:20Z")

</div>

I’m trying to use nginx for load balancing in my server.  
Actually I have 2 servers in the same network with Apache listening the  
port 8080 ([http://IP:8080/](http://IP:8080/) it’s works!). In one of them i install nginx  
to  
send 50% of requests to one server and 50% to other. The configuration  
looks like:

upstream mysite{  
server 10.10.14.64:8080;  
server 127.0.0.1:8080;  
}

server {  
server\_name 10.10.14.66;

# pass all else onto apache waiting at localhost:8080

location / {  
proxy\_pass [http://mysite](http://mysite);  
}  
}

When i run ‘‘ab -c 100 -n 1000 [http://10.10.14.66/prueba.php](http://10.10.14.66/prueba.php)’’, where  
prueba.php only does ‘‘phpinfo()’’. The result show:  
…  
Complete requests: 1000  
Failed requests: 499  
(Connect: 0, Receive: 0, Length: 499, Exceptions: 0)  
…  
But if i run the same benchmark individually, there are 0 Fail requests.  
Just commenting one server or the other from upstream nginx  
configuration.

If i try with a html or jpg file don’t get fail requests. But the times  
don’t improve with the 2 servers. If i does the test directly to port  
8080 for each machine, i get 5-6 seg average, but if i does to nginx  
with load balance, i get 7-8 seg average. It’s that reasonable?

Can anyone help me?

---

<div class="post-metadata">

**Author:** ![miquel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@miquel](https://www.ruby-forum.com/u/miquel)\
**Post date:** [November 10, 2010, 4:49pm UTC](https://www.ruby-forum.com/t/50-of-failed-requests-with-load-balance/198913/2 "2010-11-10T16:49:59Z")

</div>

> Complete requests: 1000  
> Failed requests: 499  
> (Connect: 0, Receive: 0, Length: 499, Exceptions: 0)

It’s just the content-length error and nothing else - ‘ab’ kinda  
measures  
only the first response and if the following requests differ in size its  
considered as error - loadbalancing between 2 servers where \<? phpinfo(); ?\>  
has different output will lead to ab showing that half requests have  
failed.

In general phpinfo() is kinda quite slow for testing - I would suggest  
to  
test something more generic like \<? echo 'hello world'; ?\>

> If i try with a html or jpg file don’t get fail requests. But the times  
> don’t improve with the 2 servers. If i does the test directly to port  
> 8080 for each machine, i get 5-6 seg average, but if i does to nginx  
> with load balance, i get 7-8 seg average. It’s that reasonable?

First - its good to run ‘ab’ from different box than the webserver  
itself as  
its quite a resource hog and can slow down the webserver itself  
(especially  
if the box isnt very fast) and then compare the results.

Second - no matter how you look at it a loadbalancer is extra layer  
between  
client and server so if each server can push 10 requests per second it  
doesnt always mean you will see 20 req/sec speed from the balancer.

rr
