Apache Configuration
The supported load balancing configuration includes Apache 2 + mod_jk. This document assumes that Apache 2 will load mod_jk as a shared module. This document also assumes that the reader has some familiarity with configuring Apache. A tutorial / guide to building and configuring Apache may be provided later.
Once Apache 2 and mod_jk have been built, ensure that the following configuration file changes are made:
${apache.home}/conf/httpd.conf:
LoadModule jk_module modules/mod_jk.so
JkWorkersFile workers.properties
JkShmFile mod_jk.shm
JkLogFile logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkMount /* loadbalancer
The JkMount directive assumes that the sole purpose of this apache instance is to proxy to a group of CS5.0 machines. If this is not the case, one may provide these directives in the context of a virtual host.
Note also that depending on how Apache is launched on your system, it may be necessary to provide full paths to the shared memory file, log file, and workers file.
${apache.home}/workers.properties:
# Define the load balancer worker
worker.list=loadbalancer
worker.xpproone.type=ajp13
worker.xpproone.host=192.168.168.128
worker.xpproone.port=8009
worker.xpproone.lbfactor=1
worker.xpprotwo.type=ajp13
worker.xpprotwo.host=192.168.168.130
worker.xpprotwo.port=8009
worker.xpprotwo.lbfactor=1
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=xpproone, xpprotwo
The workers.properties file is the configuration file that mod_jk uses to determine where to relay requests. We’ll go over each one of the lines in this configuration:
# Define the load balancer worker
worker.list=loadbalancer
This defines the load balancer worker. It will distribute requests to each CS5.0 server.
worker.xpproone.type=ajp13
worker.xpproone.host=192.168.168.128
worker.xpproone.port=8009
worker.xpproone.lbfactor=1
Defines a worker called xpproone. This must be the same name as that node’s jvmRoute attribute in server.xml. This worker is available at 192.168.168.128. Note that the port should be the same across all instances. This worker has a load factor of 1. Higher load factors will get more requests from mod_jk.
worker.xpprotwo.type=ajp13
worker.xpprotwo.host=192.168.168.130
worker.xpprotwo.port=8009
worker.xpprotwo.lbfactor=1
Similarly defines a worker called xpprotwo. The semantics in the previous section also apply here.
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=xpproone, xpprotwo
Defines the loadbalancer worker to be special type of worker that can distribute requests to other workers. Configures that worker to distribute its requests to xpproone and xpprotwo.