Haproxy VS Nginx 均衡负载/反向代理性能哪个牛?

范堡 发布于 2010/03/03 06:37
阅读 12K+
收藏 6

测试环境:

CPU:Xeon2.8G X2 
RAM:4G
OS:RedHat As5.3 X64

工具:apache ab
参数:ab -i -c 500 -n 100000

最终服务端:2个squid 需实现均衡负载

成绩如下:

####### Nginx + haproxy :  (由Nginx通过反向代理发送请求至haproxy, 并由其进行均衡负载)

Concurrency Level:      500
Time taken for tests:   53.758 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Total transferred:      38600386 bytes
HTML transferred:       0 bytes
Requests per second:    1860.19 [#/sec] (mean)
Time per request:       268.790 [ms] (mean)
Time per request:       0.538 [ms] (mean, across all concurrent requests)
Transfer rate:          701.21 [Kbytes/sec] received

 

####### haproxy :  (单独由haproxy进行均衡负载)

Concurrency Level:      500
Time taken for tests:   32.562 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Total transferred:      36606588 bytes
HTML transferred:       0 bytes
Requests per second:    3071.02 [#/sec] (mean)
Time per request:       162.812 [ms] (mean)
Time per request:       0.326 [ms] (mean, across all concurrent requests)
Transfer rate:          1097.85 [Kbytes/sec] received

 

####### nginx : (单独由nginx进行均衡负载)

Concurrency Level:      500
Time taken for tests:   36.539 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Total transferred:      38600000 bytes
HTML transferred:       0 bytes
Requests per second:    2736.82 [#/sec] (mean)
Time per request:       182.694 [ms] (mean)
Time per request:       0.365 [ms] (mean, across all concurrent requests)
Transfer rate:          1031.65 [Kbytes/sec] received

 

反复测试,得出其结果:

Haproxy 单独进行均衡负载的性能最强,超过了Nginx。
然而 Nginx + Haproxy 的搭配性能最弱,应该是跟通过了2层反向代理有关。

所以想用 Haproxy 替代 Nginx 所自带的均衡负载功能将会令性能打折。
但 Nginx 的配置法则确远比 Haproxy 灵活。

还是视乎用途而决定吧。

加载中
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部