HAProxyはいかがでしょうか。高性能なソフトウェアロードバランサです。
ApacheのLISTENポートを8080等に変更し、HAProxyで以下の設定を入れます。
以下の例は同時接続数を100に制限する場合です。
xxx.xxx.xxx.xxx:80には元々ApacheがLISTENしていたアドレスを、yyy.yyy.yyy.yyy:8080にはApacheがLISTENしているアドレスに置き換えてください。
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 30000
user root
group root
daemon
defaults
mode http
log global
option httplog
option dontlognull
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 30000
frontend www
bind xxx.xxx.xxx.xxx:80
default_backend www_backend
backend www_backend
mode http
balance leastconn
option forwardfor
#option httpchk GET /path/to/health_check
#http-check expect status 200
timeout server 60s
server www_01 yyy.yyy.yyy.yyy:8080 weight 1 maxconn 100 check inter 10s rise 2 fall 2
負荷が集中したページ配下のみで制御するには、ある程度ディレクトリを分割してbackend www_backendを定義します。
以下の例では、/dir1を接続数10, /dir2を接続数20、/dir3を接続数30に制限しています。
frontend www
bind xxx.xxx.xxx.xxx:80
acl acl_dir1 path_beg /dir1
acl acl_dir2 path_beg /dir2
acl acl_dir3 path_beg /dir3
use_backend www_backend_dir1 if acl_dir1
use_backend www_backend_dir2 if acl_dir2
use_backend www_backend_dir3 if acl_dir3
default_backend www_backend
backend www_backend
mode http
balance leastconn
option forwardfor
#option httpchk GET /path/to/health_check
#http-check expect status 200
timeout server 60s
server www_01 yyy.yyy.yyy.yyy:8080 weight 1 maxconn 100 check inter 10s rise 2 fall 2
backend www_backend_dir1
mode http
balance leastconn
option forwardfor
#option httpchk GET /path/to/health_check
#http-check expect status 200
timeout server 60s
server www_01 yyy.yyy.yyy.yyy:8080 weight 1 maxconn 10 check inter 10s rise 2 fall 2
backend www_backend_dir2
mode http
balance leastconn
option forwardfor
#option httpchk GET /path/to/health_check
#http-check expect status 200
timeout server 60s
server www_01 yyy.yyy.yyy.yyy:8080 weight 1 maxconn 20 check inter 10s rise 2 fall 2
backend www_backend_dir3
mode http
balance leastconn
option forwardfor
#option httpchk GET /path/to/health_check
#http-check expect status 200
timeout server 60s
server www_01 yyy.yyy.yyy.yyy:8080 weight 1 maxconn 30 check inter 10s rise 2 fall 2
退会済みユーザー
2016/09/21 04:55