httpd mod_proxy 와 tomcat lb 설정에 따른 load balancer 구현
ITWeb/서버관리 2013. 11. 22. 15:55[httpd 의 mod_proxy 를 이용한 load balancing 구현]
<VirtualHost dev.session-cluster.com:80>
ServerAdmin howook.jeong@nhn.com
DocumentRoot "D:\Application\httpd\htdocs\session_cluster\web"
ServerName dev.session-cluster.com
ServerAlias dev.session-cluster.com
ErrorLog "D:/Application/httpd/logs/dev.session-cluster.com-error.log"
CustomLog "D:/Application/httpd/logs/dev.session-cluster.com-access.log" common
DirectoryIndex index.html index.jsp
ProxyPass /cluster balancer://mycluster
ProxyPassReverse /cluster ajp://10.67.8.113:8009/
ProxyPassReverse /cluster ajp://10.67.8.113:8109/
<Proxy balancer://mycluster>
BalancerMember ajp://10.67.8.113:8009/ loadfactor=1 route=tomcat1
BalancerMember ajp://10.67.8.113:8109/ loadfactor=1 route=tomcat2
ProxySet lbmethod=byrequests
</Proxy>
<Directory "D:\Application\httpd\htdocs\session_cluster\web">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from All
</Directory>
</VirtualHost>
※ ProxyRequests Off 를 설정 하게 되면 ProxySet lbmethod=byrequests 가 동작 하지 않습니다.
※ 위와 같이 적용했을 경우 mod_jk.so 를 통한 연결은 필요가 없습니다. 이유는 mod_proxy_ajp.so 를 이용해서 연결을 하기 때문 입니다.
[참고자료]
- http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
Parameter | Default | Description |
---|---|---|
lbmethod | byrequests | Balancer load-balance method. Select the load-balancing scheduler method to use. Either byrequests , to perform weighted request counting, bytraffic , to perform weighted traffic byte count balancing, or bybusyness (Apache HTTP Server 2.2.10 and later), to perform pending request balancing. Default is byrequests . |
maxattempts | One less than the number of workers, or 1 with a single worker. | Maximum number of failover attempts before giving up. |
nofailover | Off | If set to On the session will break if the worker is in error state or disabled. Set this value to On if backend servers do not support session replication. |
stickysession | - | Balancer sticky session name. The value is usually set to something like JSESSIONID or PHPSESSIONID , and it depends on the backend application server that support sessions. If the backend application server uses different name for cookies and url encoded id (like servlet containers) use | to to separate them. The first part is for the cookie the second for the path. |
scolonpathdelim | Off | If set to On the semi-colon character ';' will be used as an additional sticky session path deliminator/separator. This is mainly used to emulate mod_jk's behavior when dealing with paths such as JSESSIONID=6736bcf34;foo=aabfa |
timeout | 0 | Balancer timeout in seconds. If set this will be the maximum time to wait for a free worker. Default is not to wait. |
failonstatus | - | A single or comma-separated list of HTTP status codes. If set this will force the worker into error state when the backend returns any status code in the list. Worker recovery behaves the same as other worker errors. Available with Apache HTTP Server 2.2.17 and later. |
※ 이전 글 Tomcat Sessoin Clustering 과 연관 해서 load balance 를 적용해 보시는 것도 성능에 도움이 될 수 있습니다.