mod_proxy_balancerを試してみた
Apache2.2.3をソースからインストールしたので、同一マシン内にポート8080〜8083で合計4プロセス起動。8080をバランサーとして設定。
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule proxy_balancer_module modules/mod_proxy_balancer.so ProxyPass / balancer://server/ <Proxy balancer://server> BalancerMember http://server:8081 keepalive=On loadfactor=1 BalancerMember http://server:8082 keepalive=On loadfactor=2 BalancerMember http://server:8083 keepalive=On loadfactor=3 </Proxy>
これでブラウザからアクセスすると、良い感じに1:2:3の割合で各Apacheにリクエストが振り分けられた。
ということで、今度は同一LAN上のマシン(WinXP)からabを使ってアクセス。また、500リクエストぐらい投げたところで8082ポートのApacheをstopしてみた。
C:\usr\local\apache2.2\bin>ab -c 10 -n 1000 server:8080/phpinfo.php This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright 1997-2005 The Apache Software Foundation, http://www.apache.org/ Benchmarking server (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Finished 1000 requests Server Software: Apache/2.2.3 Server Hostname: server Server Port: 8080 Document Path: /phpinfo.php Document Length: 3180 bytes Concurrency Level: 10 Time taken for tests: 47.171875 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 3414000 bytes HTML transferred: 3180000 bytes Requests per second: 21.20 [#/sec] (mean) Time per request: 471.719 [ms] (mean) Time per request: 47.172 [ms] (mean, across all concurrent requests) Transfer rate: 70.66 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 3.2 0 62 Processing: 93 467 61.2 468 1828 Waiting: 46 369 87.6 375 1593 Total: 93 468 60.9 468 1828 Percentage of the requests served within a certain time (ms) 50% 468 66% 468 75% 468 80% 468 90% 484 95% 484 98% 484 99% 562 100% 1828 (longest request) C:\usr\local\apache2.2\bin>
たまたまかも知れないがエラーなし。というより、メンバーがダウンした後も残りのメンバーにちゃんと振り分けられていることが確認できた。