8 Replies Latest reply on Nov 28, 2003 3:41 PM by aalmero

    Apache2+Tomcat+Mod_Jk2 doesn't load balance?

    xavi78


      Hi all,

      I have 2 machine. 1 has 1 Apache2 and 1 JBoss 3.2.1. The other has 1 JBoss3.2.1. All machines use RedHat Linux. I've managed to get the two JBoss clustered and also connected to Apache using JK2. And yes, I've already add jvmRoute to my jboss-tomcat.

      I'm doing stress test to my application. From what I saw, the requests always redirect to 1 JBoss only. The load balancing doesn't work although the failover works correctly.

      Can anyone help me out with this. Any help will be greatly appreciated.

      xavi

      Here's the content of my workers2.properties:

      [shm:]
      file=/usr/local/apache2/logs/jk2.shm
      size=1048576

      [lb:lb_01]
      info=Default Load Balancer.
      debug=1
      stickySession=1

      [channel.socket:server1:8009]
      info=Ajp13 forwarding over socket
      tomcatId=node1
      lb_factor=50
      group=lb_01
      disabled=0


      [channel.socket:server2:8009]
      info=Ajp13 forwarding over socket
      tomcatId=node2
      lb_factor=100
      group=lb_01
      disabled=0

      [uri:/*]
      group=lb_01
      debug=1

      [logger]
      level=INFO

      [config:]
      file=/usr/local/apache2/conf/workers2.properties
      debug=1
      debugEnv=0

        • 1. Re: Apache2+Tomcat+Mod_Jk2 doesn't load balance?
          camel

          I noticed that you had lb_factor=50 for one node and lb_factor=100 for the other. I may be wrong here (I haven't used jk2 for load balancing, but i skimmed the docs) -- are the lb factors supposed to add up to 100?

          • 2. Re: Apache2+Tomcat+Mod_Jk2 doesn't load balance?
            mikefinn

            How are you stress testing? Does your test tool establish new HTTP sessions? If not, all requests will be routed to the node to which the one session is bound (sticky sessions).

            Mike

            • 3. Re: Apache2+Tomcat+Mod_Jk2 doesn't load balance?
              mmcnamee

              I have successfully setup Apache 1.3.27 + ModSSL and ModJK, connecting to JBoss 3.2.1 with Jetty. The load balancing works ok, I think I had a lbfactor of 5 and 10. One simple test you can perform, is to hit the webpages continously with a browser (or an automated tool)..and stutdown the primary Jboss server, all the traffic should automatically failover to the second, although sessions will be lost if you don't have session replication turned on (I didn't). If this is of any use to you, I can get more detailed configuration information for you.

              Mark

              • 4. Re: Apache2+Tomcat+Mod_Jk2 doesn't load balance?
                xavi78

                I'm using Microsoft Web Application Stress Tool. I think it uses new HttpSession for every hit to the system.

                • 5. Re: Apache2+Tomcat+Mod_Jk2 doesn't load balance?
                  mikefinn

                  You need to make sure that's the case. Your system is behaving as it should if there is one session. You said failover is working, which I assume means the LB will route new sessions to a good node if one node is dropped. If that's the case, JK2 is probably working. As far as I can see, workers2.properties looks fine.

                  You can make sure the session LB works simply by using a browser. As a test, set your lb_factors to the same value. I don't think it matters what that number is (just not zero). They are normalized to each other, IIRC. So w/ 100 & 50, the 100 will get 2x the requests as the 50. Then access the application from a browser, then login to the app from another machine, or another browser on the same machine (IE, then Mozilla). Those sessions should get established on two different nodes.

                  Does your jvmRoute in jboss-service.xml match the respective tomcatId?

                  I have a similar config working here (except it's JBoss 3.2.2). I'd be happy to share config files.

                  Mike

                  • 6. Re: Apache2+Tomcat+Mod_Jk2 doesn't load balance?
                    xavi78


                    Hi,

                    Thanks for the reply. I've set the tomcatId as same as jvmRoute in jboss-service.xml. I'll try new test using your test scenario.

                    thanks

                    • 7. Re: Apache2+Tomcat+Mod_Jk2 doesn't load balance?
                      ericmacau

                      Hi Mark,

                      Would you please to teach me how to enable session replication?

                      I can setup Apache2+Jk2+JBoss-Tomcat in Load Balance.

                      But I don't know how to keep the session?

                      Eric

                      • 8. Re: Apache2+Tomcat+Mod_Jk2 doesn't load balance?
                        aalmero

                        my setup is working fine only that i did not specify
                        the group properties in the ff.

                        [uri:/*]
                        debug=1

                        aalmero