13.4.4. Configuration Reference for Apache Mod_jk Workers

The workers.properties file defines the behavior of the worker nodes which mod_jk passes client requests to. In Red Hat Enterprise Linux, the file resides in /etc/httpd/conf/workers.properties. The workers.properties file defines where the different servlet containers are located, and the way the work load should be balanced across them.
The configuration is divided into three sections. The first section deals with global properties, which apply to all worker nodes. The second section contains settings which apply to a specific worker. The third section contains settings which apply to a specific node balanced by the worker.
The general structure of a property is worker.WORKER_NAME.DIRECTIVE, where WORKER_NAME is a unique name for the worker, and DIRECTIVE is the setting to be applied to the worker.
Configuration reference for Apache mod_jk workers

Node templates specify default per-node settings. You can override the template within the node settings itself. You can see an example of node templates in Example 13.6, “Example workers.properties file”.

Table 13.14. Global properties

Property Description
worker.list The list of worker names used by mod_jk. These workers are available to receive requests.

Table 13.15. Per-worker properties

Property Description
type
The type of the worker. The default type is ajp13. Other possible values are ajp14, lb, status.
For more information on these directives, refer to the Apache Tomcat Connector AJP Protocol Reference at http://tomcat.apache.org/connectors-doc/ajp/ajpv13a.html.
balance_workers
Specifies the worker nodes that the load balancer must manage. You can use the directive multiple times for the same load balancer. It consists of a comma-separated list of worker names. This is set per worker, not per node. It affects all nodes balanced by that worker type.
sticky_session
Specifies whether requests from the same session are always routed to the same worker. The default is 0, meaning that sticky sessions are disabled. To enable sticky sessions, set it to 1. Sticky sessions should usually be enabled, unless all of your requests are truly stateless. This is set per worker, not per node. It affects all nodes balanced by that worker type.

Table 13.16. Per-node properties

Property Description
host
The hostname or IP address of the worker. The worker node must support the ajp protocol stack. The default value is localhost.
port
The port number of the remote server instance listening for defined protocol requests. The default value is 8009, which is the default listening port for AJP13 workers. The default value for AJP14 workers is 8011.
ping_mode
The conditions under which connections are probed for network status. The probe uses an empty AJP13 packet for CPing, and expects a CPong in response. Specify the conditions by using a combination of directive flags. The flags are not separated by a comma or any white-space. The ping_mode can be any combination of C, P, I, and A.
  • C - Connect. Probe the connection one time after connecting to the server. Specify the timeout using the value of connect_timeout value. Otherwise, the value of ping_timeout is used.
  • P - Prepost. Probe the connection before sending each request to the server. Specify the timeout using the prepost_timeout directive. Otherwise, the value of ping_timeout is used.
  • I - Interval. Probe the connection at an interval specified by connection_ping_interval, if present. Otherwise, the value of ping_timeout is used.
  • A - All. A shortcut for CPI, which specifies that all connection probes are used.
ping_timeout, connect_timeout, prepost_timeout, connection_ping_interval
The timeout values for the connection probe settings above. The value is specified in milliseconds, and the default value for ping_timeout is 10000.
lbfactor
Specifies the load-balancing factor for an individual worker, and only applies to a member worker of a load balancer. This is useful to give a more powerful server more of the work load. To give a worker 3 times the default load, set this to 3: worker.my_worker.lbfactor=3

Example 13.6. Example workers.properties file

worker.list=ajp13,lb
     
worker.balancer1.sticky_sessions=1
worker.balancer1.balance_workers=node1
worker.balancer2.sticky_session=1
worker.balancer2.balance_workers=node2,node3

worker.nodetemplate.type=ajp13
worker.nodetemplate.port=8009

worker.node1.template=nodetemplate
worker.node1.host=localhost
worker.node1.ping_mode=CI
worker.node1.connection_ping_interval=9000
worker.node1.lbfactor=1

worker.node1.template=nodetemplate
worker.node2.host=192.168.1.1
worker.node2.ping_mode=A

worker.node1.template=nodetemplate
worker.node3.host=192.168.1.2
Further configuration details for Apache mod_jk are out of the scope of this document. Refer to the Apache documentation at http://tomcat.apache.org/connectors-doc/ for further instructions.