1. 개요

지난 글에 이은, workers.properties 2편이다.


2. 설정

ping_mode는 Tomcat Connectors 1.2.27 이상에서 사용 가능하다. Apache HTTP Server에서 CPing/CPong을 이용하여 Tomcat 인스턴스의 상태를 확인하는 방법으로 다음과 같은 조합이 있다.

  • C (Connect) : Tomcat에 연결한 후 CPing/CPong시 connect_timeout만큼 기다리며, 지정되지 않은 경우 ping_timeout 을 기다린다.
  • P (Preport) : Tomcat 에 요청을 보내기 전 CPing/CPong하여 연결을 확인한다. prepost_timeout만큼 기다리며, 지정되지 않은 경우 ping_timeout 만큼 기다린다.
  • I (Interval) : 주기적으로 connect_ping_interval만큼 CPing/CPong하여 연결을 확인한다..
  • A (All) : 위의 모든 방법을 사용한다.

ping_timeout은 기본 10000(ms) 즉 10초이며, connect_timeout과 prepost_timeout 은 기본 0으로 무제한이다.

Apache HTTP Server가 DMZ에 위치하고 있는 등의 이유로 Apache HTTP Server 와 Tomcat 간에 방화벽(Firewall)이 존재하는 경우 connection_pool_timeout 과 socket_keepalive에 보다 신경써야 한다. 만일 방화벽에 세션 타임아웃 설정이 있는 경우 connection_pool_timeout 은 그 보다 작게 설정한다.

그리고 Apache HTTP Server의 connection_pool_timeout 과 Tomcat AJP 커넥터의 connectionTimeout은 동일하게 맞춰준다. 참고로,

1. Apache HTTP Server의 connection_pool_timeout

You should keep this time interval in sync with the keepAliveTimeout attribute (if it is set explicitly) or connection-timeout attribute of your AJP connector in Tomcat's server.xml. Note however, that the value for mod_jk is given in seconds, the one in server.xml has to use milliseconds.

2. Tomcat의 connectionTImeout

The number of milliseconds this Connector will wait, after accepting a connection, for the request URI line to be presented. The default value for AJP protocol connectors is -1 (i.e. infinite).

3.  Tomcat의 keepAliveTimeout

The number of milliseconds this Connector will wait for another AJP request before closing the connection. The default value is to use the value that has been set for the connection-timeout attribute.

-> 명시적으로 설정하지 않으면 connectionTimeout과 동일하게 keepAliveTimeout가 적용된다. 

socket_keepalive는 기본 False이므로 웹 사이트의 특성에 따라 이 기능을 사용하고자 하는 경우 True로 설정하면 된다.

위의 예에서 connection_pool_timeout은 60초로 설정되어 있다. 그리고 Tomcat의 conf/server.xml에서도 ajp connector의 connectionTimeout을 60초로 설정한다. 단, 여기서의 단위는 ms이므로 60초인 경우 60000으로 설정한다. (connectionTimeout="60000")