---
title: "pound vs mod_proxy_balancer"
author: "jedy"
date: "2006-07-20T06:50:00Z"
tags: []
slug: "pound-vs-mod-proxy-balancer"
draft: false
lastmod: "2006-07-20T06:50:00Z"
id: 304728
url: "https://jedy.iteye.com/blog/304728"
---

今天对pound和apache2.2的mod\_proxy\_balancer对了一下性能比较。  
安装基本都是默认的，设置也很简单。  
pound:

```

LogLevel 3

ListenHTTP
        Address 192.168.2.83
        Port    81
        Service
                BackEnd
                        Address 192.168.3.37
                        Port    80
                End
                BackEnd
                        Address 192.168.3.201
                        Port    80
                End
        End
End

```

apache:

```

<location>
SetHandler balancer-manager

Order Deny,Allow
Allow from all
</location>


ProxyRequests off
<proxy>
    Order deny,allow
    Allow from all
</proxy>

ProxyPass / balancer://mytest/
<proxy balancer://mytest/>
    BalancerMember http://192.168.3.201  loadfactor=1
    BalancerMember http://192.168.3.37   loadfactor=1
</proxy>
```

pound和apache都可以实现无缝的切换，即有一台死了，所有的访问都会自动放到另一台上。  
不过apache刚开始测试时，会出现一次proxy error页面，之后就没有了。后来的测试中没有再出现过。原因不明。  
apache的balancer-manager可以查看状态，并可以及时在页面上设置balancer的参数，比较方便。  
性能测试用的ab  
ab -n 3000 -c 100  
测了几次，结果都类似  
pound:

```

Requests per second:    136.67 [#/sec] (mean)
Time per request:       731.70 [ms] (mean)
Time per request:       7.32 [ms] (mean, across all concurrent requests)
Transfer rate:          188.55 [Kbytes/sec] received

Connnection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0     2   77.4      0  2999
Processing:    -3   704  715.0    181  1754
Waiting:       -4   704  715.1    180  1753
Total:         -3   707  718.9    202  4348

Percentage of the requests served within a certain time (ms)
  50%    202
  66%   1337
  75%   1417
  80%   1478
  90%   1574
  95%   1615
  98%   1645
  99%   1657
 100%   4348 (last request)
```

apache:

```

Requests per second:    171.41 [#/sec] (mean)
Time per request:       583.40 [ms] (mean)
Time per request:       5.83 [ms] (mean, across all concurrent requests)
Transfer rate:          228.78 [Kbytes/sec] received

Connnection Times (ms)
              min  mean[+/-sd] median   max
Connect:       -2     9  154.6      0  3003
Processing:    -3   338 1662.0     26 13940
Waiting:       -4   337 1662.0     25 13939
Total:         -3   347 1667.9     26 13941

Percentage of the requests served within a certain time (ms)
  50%     26
  66%     41
  75%     49
  80%     54
  90%     79
  95%    303
  98%   7398
  99%  10753
 100%  13941 (last request)
```

可以看到，apache的平均时间短，但方差太大，而且最长达到14秒，基本上已经很难忍受了。  
pound虽然单个时间比较大，但都很平均，不会有太长的。所以觉得pound比较理想。  
不过测试过程中pound的服务器死掉了一次，不知道是什么原因。