• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Load balancing in Apache Web server not working

 
Greenhorn
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 23
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

can you check, if two of the instances are running independently first?
Your Error log shows, that it could not find one of the instance. Look for the possible port conflict.

Best practice to assign ports to two different servers is to change the post base...
i.e. default tomact might be running on 8080, portbase is 8
for another instance, have the portbase 9, running it on 9080

your configuration seems fine. Please check your servers have the HTTP- listener enabled on on the specified ports i.e. 8009 and 8109
and the network-listener jk is enabled.
reply
    Bookmark Topic Watch Topic
  • New Topic