Discussion:
Load Balancing to Tomcat Workers
Loai Abdallatif
2018-10-03 20:07:12 UTC
Permalink
Hello,

I have configures web server with jk load balancer to tomcat server
(192.168.237.11) with two containers worker 0, worker1)
the problem is that the web application session seems keep rotating between
both workers but I need session stickeness, means the client will be
connected to the same worker which doesn't occur ,

the workers.properties file has this content :
worker.list=EVOUCHER_LB, jk-status, jk-manager, EVOUCHER_LB
# Define worker0 -- appserver1
worker.worker_app1.type=ajp13
worker.worker_app1.host=192.168.237.11
worker.worker_app1.port=8009
worker.worker_app1.socket_timeout=1200
worker.worker_app1.connection_pool_size=1
worker.worker_app1.connection_pool_timeout=1300
worker.worker_app1.lbfactor=1
worker.worker_app1.redirect=worker_app2
worker.worker_app1.sticky_session=1
#############################################################
#Define worker1 -- appserver1
worker.worker_app2.type=ajp13
worker.worker_app2.host=192.168.237.11
worker.worker_app2.port=8109
worker.worker_app2.socket_timeout=1200
worker.worker_app2.connection_pool_size=1
worker.worker_app2.connection_pool_timeout=1300
worker.worker_app2.lbfactor=1
worker.worker_app2.redirect=worker_app1
worker.worker_app2.sticky_session=1
Christopher Schultz
2018-10-03 20:40:25 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Loai,
Post by Loai Abdallatif
Hello,
I have configures web server with jk load balancer to tomcat
server (192.168.237.11) with two containers worker 0, worker1) the
problem is that the web application session seems keep rotating
between both workers but I need session stickeness, means the
client will be connected to the same worker which doesn't occur ,
Sticky sessions are the default.
Post by Loai Abdallatif
worker.list=EVOUCHER_LB, jk-status, jk-manager, EVOUCHER_LB #
Define worker0 -- appserver1 worker.worker_app1.type=ajp13
worker.worker_app1.host=192.168.237.11
worker.worker_app1.port=8009
worker.worker_app1.socket_timeout=1200
worker.worker_app1.connection_pool_size=1
worker.worker_app1.connection_pool_timeout=1300
worker.worker_app1.lbfactor=1
worker.worker_app1.redirect=worker_app2
worker.worker_app1.sticky_session=1
You haven't specified a route name. Is the jvmRoute for your
192.168.237.11 set to "worker_app1"? If not, you'll have to set
worker.worker_app1.route=routeName and do the same in your <Engine>
for your jvmRoute attribute.
Post by Loai Abdallatif
#############################################################
#Define worker1 -- appserver1 worker.worker_app2.type=ajp13
worker.worker_app2.host=192.168.237.11
worker.worker_app2.port=8109
worker.worker_app2.socket_timeout=1200
worker.worker_app2.connection_pool_size=1
worker.worker_app2.connection_pool_timeout=1300
worker.worker_app2.lbfactor=1
worker.worker_app2.redirect=worker_app1
worker.worker_app2.sticky_session=1
Same here.

Read the workers.properties documentation[1] for these settings just
to make sure you understand everything before you start changing
things. Specifically, read the introduction to the "Load Balancing
Directives" section (which specifically, in RED TEXT, warns you about
setting these parameters and making sure they agree). Read about the
"route" attribute and also read about "redirect" (which shouldn't be
necessary unless there is a specific reason to fail-over to one worker
specifically, as opposed to one in particular). The only use-case I
can think of for "redirect" is when you are using the BackupManager
for session-clustering.

Hope that helps,
- -chris

[1] http://tomcat.apache.org/connectors-doc/reference/workers.html
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlu1KTkACgkQHPApP6U8
pFipzhAAt4Z6gqyIjLn+gDMVXeQU9FxXhkRSdRnDN7M1ZDbz0hMoNkTzkWz++w/L
F2Y47n8RbLydwM7KGKFoKK8uWud4APAXtSPamlRuleAp9fajTbNSAtfs0zTQLGZc
teDwmBuxYWgtpnmhzPEWfZ03MLzbkprt5Z3nREu0Zbt34Z0VFCJ5v1Q/i3fJjP9M
2XyU/KbSrLAqn6bZwhpqVVS6kbQq0wCabbz5yoDfh8T2t1pehnfMCq3RrXr9q8Kb
8uS5aKnXyQkLPse9OFGNDGMFkL3Q3dSc0jWZXzQnerX/EgDrQqHfURqHcXS795WP
5uF0k04boIx91SJLov/H4dDzWj5eT70PL/9dxQaJcradVYquFxI/FgXnuDtvvyFF
MOT52NyFs95LpAUZ4WoQEWAGfsg8Zk/Btz6e97RYQ2fCm2c7xHnNRWK/63T9fEHl
YwBlp3G4XHWI2PoalA+CVrm3/xJd7noDSBHjpq2CN+0npBDJFvT01cupzJybPKVF
k9tqK/KB1BOqn2LL7V7e+1xKcADF5XB5/Kbq66qAAgkYducMnrZUVcphfWhdnXG0
r4+Mnt2enpcmdpLGL8/+AK/iYiOz79PDe7xPKJdMNpD7jAyZQD+7bghcPbXOujdW
K6OOvLHLDQ6P1Om+fT7WGQZnd5dDDpJaQqquEsYNAUA2bFQdwvg=
=+5Fi
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Rainer Jung
2018-10-04 07:35:36 UTC
Permalink
Just adding a bit below ...
Post by Christopher Schultz
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Loai,
Post by Loai Abdallatif
Hello,
I have configures web server with jk load balancer to tomcat
server (192.168.237.11) with two containers worker 0, worker1) the
problem is that the web application session seems keep rotating
between both workers but I need session stickeness, means the
client will be connected to the same worker which doesn't occur ,
Sticky sessions are the default.
Post by Loai Abdallatif
worker.list=EVOUCHER_LB, jk-status, jk-manager, EVOUCHER_LB #
Define worker0 -- appserver1 worker.worker_app1.type=ajp13
worker.worker_app1.host=192.168.237.11
worker.worker_app1.port=8009
worker.worker_app1.socket_timeout=1200
worker.worker_app1.connection_pool_size=1
worker.worker_app1.connection_pool_timeout=1300
worker.worker_app1.lbfactor=1
worker.worker_app1.redirect=worker_app2
worker.worker_app1.sticky_session=1
You haven't specified a route name. Is the jvmRoute for your
192.168.237.11 set to "worker_app1"? If not, you'll have to set
worker.worker_app1.route=routeName and do the same in your <Engine>
for your jvmRoute attribute.
Post by Loai Abdallatif
#############################################################
#Define worker1 -- appserver1 worker.worker_app2.type=ajp13
worker.worker_app2.host=192.168.237.11
worker.worker_app2.port=8109
worker.worker_app2.socket_timeout=1200
worker.worker_app2.connection_pool_size=1
worker.worker_app2.connection_pool_timeout=1300
worker.worker_app2.lbfactor=1
worker.worker_app2.redirect=worker_app1
worker.worker_app2.sticky_session=1
Same here.
Read the workers.properties documentation[1] for these settings just
to make sure you understand everything before you start changing
things. Specifically, read the introduction to the "Load Balancing
Directives" section (which specifically, in RED TEXT, warns you about
setting these parameters and making sure they agree). Read about the
"route" attribute and also read about "redirect" (which shouldn't be
necessary unless there is a specific reason to fail-over to one worker
specifically, as opposed to one in particular). The only use-case I
can think of for "redirect" is when you are using the BackupManager
for session-clustering.
I don't see a balancer worker defined (type lb) and configured. Some of
the attributes you set belong to a balancer worker. I suggest reading

http://tomcat.apache.org/connectors-doc/common_howto/loadbalancers.html

The point about setting jvmRoute in your Tomcat's server.xml is very
important.

A good starting point for a mod_jk config is here:

http://svn.apache.org/viewvc/tomcat/jk/trunk/conf/

The files are also contained in the source release of mod_jk available under

https://tomcat.apache.org/download-connectors.cgi

Regards,

Rainer





---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
loai.abdallatif
2018-10-04 08:11:36 UTC
Permalink
Thanks very much Rainer . I will check deeply what you said . Thanks again 

Sent from my Samsung Galaxy smartphone.
-------- Original message --------From: Rainer Jung <***@kippdata.de> Date: 10/4/18 10:35 AM (GMT+02:00) To: Tomcat Users List <***@tomcat.apache.org> Subject: Re: Load Balancing to Tomcat Workers
Just adding a bit below ...
Post by Christopher Schultz
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Loai,
Post by Loai Abdallatif
Hello,
I have configures web server with jk load balancer to tomcat
server (192.168.237.11) with two containers  worker 0, worker1) the
problem is that the web application session seems keep rotating
between both workers but I need session stickeness, means the
client will be connected to the same worker which doesn't occur ,
Sticky sessions are the default.
Post by Loai Abdallatif
worker.list=EVOUCHER_LB, jk-status, jk-manager, EVOUCHER_LB #
Define worker0 -- appserver1 worker.worker_app1.type=ajp13
worker.worker_app1.host=192.168.237.11
worker.worker_app1.port=8009
worker.worker_app1.socket_timeout=1200
worker.worker_app1.connection_pool_size=1
worker.worker_app1.connection_pool_timeout=1300
worker.worker_app1.lbfactor=1
worker.worker_app1.redirect=worker_app2
worker.worker_app1.sticky_session=1
You haven't specified a route name. Is the jvmRoute for your
192.168.237.11 set to "worker_app1"? If not, you'll have to set
worker.worker_app1.route=routeName and do the same in your <Engine>
for your jvmRoute attribute.
Post by Loai Abdallatif
#############################################################
#Define worker1 -- appserver1 worker.worker_app2.type=ajp13
worker.worker_app2.host=192.168.237.11
worker.worker_app2.port=8109
worker.worker_app2.socket_timeout=1200
worker.worker_app2.connection_pool_size=1
worker.worker_app2.connection_pool_timeout=1300
worker.worker_app2.lbfactor=1
worker.worker_app2.redirect=worker_app1
worker.worker_app2.sticky_session=1
Same here.
Read the workers.properties documentation[1] for these settings just
to make sure you understand everything before you start changing
things. Specifically, read the introduction to the "Load Balancing
Directives" section (which specifically, in RED TEXT, warns you about
setting these parameters and making sure they agree). Read about the
"route" attribute and also read about "redirect" (which shouldn't be
necessary unless there is a specific reason to fail-over to one worker
specifically, as opposed to one in particular). The only use-case I
can think of for "redirect" is when you are using the BackupManager
for session-clustering.
I don't see a balancer worker defined (type lb) and configured. Some of
the attributes you set belong to a balancer worker. I suggest reading

http://tomcat.apache.org/connectors-doc/common_howto/loadbalancers.html

The point about setting jvmRoute in your Tomcat's server.xml is very
important.

A good starting point for a mod_jk config is here:

http://svn.apache.org/viewvc/tomcat/jk/trunk/conf/

The files are also contained in the source release of mod_jk available under

https://tomcat.apache.org/download-connectors.cgi

Regards,

Rainer





---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org

Loading...