Salem's Euphoria

Sharing Experience

Load balancing with Apache HTTP

Leave a comment

Balanced on the same server

 

workers.properties

worker.list=router,status
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
worker.worker1.local_worker=1
worker.worker1.ping_timeout=1000
worker.worker1.socket_timeout=10
worker.worker1.ping_mode=A
#sticky session is not interresting here, just for explanation
#sticky session = stick to the server that gave you the first session-id
worker.worker1.sticky_session=true
#this property will make your load balancer woprking in active passive mode
#All requests would be mapped to worker1, but
#on worker1 (server1:8009) failure, all requests will be redirected to worker2
worker.worker1.redirect=worker2

worker.worker2.port=8090
worker.worker2.host=localhost
worker.worker2.type=ajp13
worker.worker2.lbfactor=1
worker.worker2.activation=disabled
worker.worker2.ping_timeout=1000
worker.worker2.socket_timeout=10
worker.worker2.ping_mode=A
worker.worker2.local_worker=0
worker.worker2.sticky_session=true

worker.router.type=lb
worker.router.balanced_workers=worker1,worker2
worker.router.sticky_session=true
worker.status.type=status

httpd.conf

...
LoadModule jk_module modules/mod_jk.so
...
#go to the end of the file and add the
JkWorkersFile /etc/httpd/conf/workers.properties
JkShmFile /etc/httpd/logs/mod_jk.shm
JkLogFile /etc/httpd/logs/mod_jk.log
JkLogLevel debug
# Configure monitoring the LB using jkstatus
JkMount /jkstatus/* status
# Configure your applications (may be using context root)
JkMount /myRootContext* router
Advertisements

Author: Salem Ben Afia

Big Data & Java developer Search Engine Architect, Lucene Expert

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s