| ryah ( @ 2009-01-26 13:47:00 |
| Entry tags: | benchmark, rails, stats |
nginx vs haproxy vs nginx+maxconn
this data includes two runs of nginx+maxconn (AKA nginx-ey-balancer) because I was testing if commenting out a certain line of code affects the results (it doesn't)
The setup:
- haproxy-1.3.15.5 (worker process 1, maxconn 1, minconn 1)
- nginx-0.6.34 (worker process 1)
- ngx_max_connections-0.0.3 + nginx-0.6.34 (worker process 1, maxconn 1)
ab -c 30 -t 120. Behind the proxies are 3 mongrels serving a Rails application (the stats for a single one are here). (raw data and config files)


When you have flaky Rails backend processes, Nginx's behavior of dispatching requests to backends as it receives them leads to erratic response times. Sometimes Nginx responds quickly but more likely it will respond slowly:
> nginx Min. 1st Qu. Median Mean 3rd Qu. Max. 18.0 138.0 418.0 534.2 814.0 3056.0 > nginx+maxconn O Min. 1st Qu. Median Mean 3rd Qu. Max. 44.0 412.0 480.0 493.8 557.0 2389.0 > haproxy Min. 1st Qu. Median Mean 3rd Qu. Max. 247.0 413.0 475.0 479.9 537.0 2644.0
For more consistent and on average faster response times one should queue requests in the proxy and send them out to backends one or two at time.