I am trying to get the apache webserver to load balance the http request. But it is only able to forward request to 1 instance of the the
Tomcat. It will not forward request to the second instance of Tomcat.
the following is my worker.properties file:
worker.list=balancer
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
worker.worker2.port=8109
worker.worker2.host=localhost
worker.worker2.type=ajp13
worker.worker2.lbfactor=1
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers= worker1, worker2
worker.loadbalancer.method=B
and my httpd.conf file:
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkMount /* balancer
If I turn off the first Tomcat instance, I will get the Service Temporarily Unavailable error:
and in the mod_jk.log :
[Thu Feb 24 15:48:03 2011] [3188:1248] [info] jk_ajp_common.c (1215): (balancer) error sending request. Will try another pooled connection
[Thu Feb 24 15:48:03 2011] [3188:1248] [info] jk_ajp_common.c (1215): (balancer) error sending request. Will try another pooled connection
[Thu Feb 24 15:48:03 2011] [3188:1248] [info] jk_ajp_common.c (1241): (balancer) all endpoints are disconnected
[Thu Feb 24 15:48:03 2011] [3188:1248] [info] jk_ajp_common.c (1244): (balancer) increase the backend idle connection timeout or the connection_pool_minsize
[Thu Feb 24 15:48:03 2011] [3188:1248] [info] jk_ajp_common.c (1941): (balancer) sending request to tomcat failed, recoverable operation attempt=1
[Thu Feb 24 15:48:04 2011] [3188:1248] [info] jk_connect.c (451): connect to 127.0.0.1:8009 failed (errno=61)
[Thu Feb 24 15:48:04 2011] [3188:1248] [info] jk_ajp_common.c (876): Failed opening socket to (127.0.0.1:8009) (errno=61)
[Thu Feb 24 15:48:04 2011] [3188:1248] [info] jk_ajp_common.c (1273): (balancer) error connecting to the backend server (errno=61)
[Thu Feb 24 15:48:04 2011] [3188:1248] [info] jk_ajp_common.c (1941): (balancer) sending request to tomcat failed, recoverable operation attempt=2
[Thu Feb 24 15:48:04 2011] [3188:1248] [error] jk_ajp_common.c (1953): (balancer) Connecting to tomcat failed. Tomcat is probably not started or is listening on the wrong port
[Thu Feb 24 15:48:04 2011] [3188:1248] [info] mod_jk.c (2254): Service error=0 for worker=balancer
have I setup the configuration correctly? why wouldn't it access the second instance when the 1st instance has failed?
thanks.
Note: I am able to forward request to second instance of Tomcat if I specify the following: (and modify the httpd.conf file)
JkMount /taskA worker1
JkMount /taskA/* worker1
JkMount /taskB worker2
JkMount /taskB/* worker2
and even if I change my worker.properties file to the following, it is still going to the firs instance of tomcat (port 8009)
worker.worker1.port=8109
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
worker.worker2.port=8109
worker.worker2.host=localhost
worker.worker2.type=ajp13
worker.worker2.lbfactor=1