1 2 Previous Next 21 Replies Latest reply on Dec 5, 2005 10:47 AM by craigduncan

    Load-Balancing SLSB

    joff

      I'm having some trouble with loadbalancing a Stateless Session Bean. What we have is two application servers running JBoss 4.0.2.

      An incoming webservice request arrives at either one of the JBoss nodes (via a loadbalancing device in front of them) which does some processing, and then sends a message to a JMS queue.

      Then an MDB picks up this message, and does some processing. As part of this, it performs several calls to a SLSB (in a loop). We would like this SLSB to be load balanced between the two JBoss nodes (via roundrobin). At the moment, all the SLSB calls run on the same node that the calling MDB runs on.

      I am calling the SLSB via it's remote home
      Failover of the MDB seems to be working correctly, as does farm deployment

      I am calling the SLSB thus:

      Properties p = new Properties();
      p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      p.put(Context.URL_PKG_PREFIXES,"jboss.naming:org.jnp.interfaces");
      p.put(Context.PROVIDER_URL,"192.168.225.248:1100,192.168.225.245:1100");
      
      InitialContext initialContext = new InitialContext(p);
      Object obj = initialContext.lookup("TransactionConductor");
      TransactionConductorHome tcH = (TransactionConductorHome)
       PortableRemoteObject.narrow(obj,TransactionConductorHome.class);
      TransactionConductor tc = tcH.create();
      
      while (condition) {
       result = tc.doTransactionRemote(request)
      }





        • 1. Re: Load-Balancing SLSB
          joff

          Oops, hit 'submit' instead of 'preview' anyway.. to continue:

          the jboss.xml for the SLSB is:

          <session>
           <ejb-name>TransactionConductor</ejb-name>
           <jndi-name>TransactionConductor</jndi-name>
           <local-jndi-name>TransactionConductorLocal</local-jndi-name>
           <clustered>True</clustered>
           <cluster-config>
           <partition-name>DefaultPartition</partition-name>
           <home-load-balance-policy>
           org.jboss.ha.framework.interfaces.RoundRobin
           </home-load-balance-policy>
           <bean-load-balance-policy>
           org.jboss.ha.framework.interfaces.RoundRobin
           </bean-load-balance-policy>
           </cluster-config>
           </session>


          The HAJNDI section of my cluster-config.xml is:
          <mbean code="org.jboss.ha.jndi.HANamingService"
           name="jboss:service=HAJNDI">
           <depends>jboss:service=${jboss.partition.name:DefaultPartition}</depends>
           <attribute name="PartitionName">DefaultPartition</attribute>
           <!-- <attribute name="BindAddress">${jboss.bind.address}</attribute> -->
           <attribute name="BindAddress">192.168.225.245</attribute>
           <attribute name="Port">1100</attribute>
           <attribute name="Backlog">50</attribute>
           <depends optional-attribute-name="LookupPool"
           proxy-type="attribute">jboss.system:service=ThreadPool</depends>
          
           <attribute name="DiscoveryDisabled">false</attribute>
           <attribute name="AutoDiscoveryBindAddress">${jboss.bind.address}</attribute>
           <attribute name="AutoDiscoveryAddress">230.0.0.4</attribute>
           <attribute name="AutoDiscoveryGroup">1102</attribute>
           <attribute name="AutoDiscoveryTTL">16</attribute>
          
           <attribute name="RmiPort">0</attribute>
           </mbean>
          


          As far as I can tell, multicast is working - the DefaultPartition, etc is working with multicast, and I can ping 230.0.0.4 and get responses back from both nodes

          • 2. Re: Load-Balancing SLSB

            If you still have a problem, can you attach a sample client and jar file to troubleshoot it?

            -Ben

            • 3. Re: Load-Balancing SLSB
              joff

              Hi Ben

              At the URL below is an EAR containing a minimal test case for my problem. It's basically a servlet for triggering the operation, an MDB to receive the JMS message, which calls a SLSB ten times

              Souce is also included

              http://joff.googlehax.com/LBTest.zip

              PS. You will either need to add a queue/HordeExecuteBatch queue, or change the deployment to use a different queue name.

              • 4. Re: Load-Balancing SLSB
                joff

                *bump*

                Is anyone able to help me here? I'm no closer to finding the solution...

                • 5. Re: Load-Balancing SLSB
                  joff

                  Hi - the next version of my app is about to go into production, but this issue is still unresolved, and it runs jobs that can take up to a couple of hours to run - being able to balance the load of these jobs across my app servers will be a major help..... can anyone shed any light as to why the stateless session beans aren't load balancing?

                  • 6. Re: Load-Balancing SLSB
                    joff

                    i've also just added in

                    <configuration-name>Clustered Stateless SessionBean</configuration-name>

                    for my EJB DDs, but still no joy :-/

                    • 7. Re: Load-Balancing SLSB
                      tomdee

                       

                      "joff" wrote:
                      (via a loadbalancing device in front of them)


                      can't you use the same device to round-robin the request for the ejb client stub for you? especially since your bean is stateless

                      • 8. Re: Load-Balancing SLSB

                        Have you tried to test just SLSB clustering first without MDB? Check out the example there.
                        http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossHA

                        I suspect it is just some setup problem. But if you are really pressed for time for production, you should consider subsribe to JBoss support.

                        Forum post does not give you guranteed response time (if at all).

                        -Ben

                        • 9. Re: Load-Balancing SLSB

                          You don't make it clear if the MDB is being run on the different nodes in round-robin fashion. Is it? (Have you specified one of the List-based ReceiversImpl implementations that makes round-robin work?)

                          • 10. Re: Load-Balancing SLSB
                            joff

                            The MDB is run on just one node at a time, using HAJMA/HASingleton

                            • 11. Re: Load-Balancing SLSB
                              joff

                               

                              "toadie" wrote:
                              "joff" wrote:
                              (via a loadbalancing device in front of them)

                              can't you use the same device to round-robin the request for the ejb client stub for you? especially since your bean is stateless

                              I'm afraid not, the loadbalancer is only there to handle requests from the outside.. the requests are quite infrequent, but result in a long-running task, which I want to balance the load of, across the JBoss nodes

                              • 12. Re: Load-Balancing SLSB

                                OK, I know it is only being run on one node at a time, but what I'm suggesting is that if you change the attribute for ReceiversImpl to use the ReceiversImplLinkedList for the queue or ConnectionManager, you can make each message get handled on a different node, each node in turn.

                                In my own case, I have an MDB calling an SLSB, and so long as the MDB that handles the message is running on a different node for each message in the queue, the SLSB will run on the same node as that MDB.

                                The default ReceiversImpl implementation makes all messages get handled on the same machine as the queue untill the load is too high there. See http://jboss.org/index.html?module=bb&op=viewtopic&t=67524.

                                • 13. Re: Load-Balancing SLSB

                                  Just so we're clear, this round-robin MDB handling is running using HAJMA/HASingleton, so fail-over works too.

                                  • 14. Re: Load-Balancing SLSB
                                    joff

                                     

                                    "ben.wang@jboss.com" wrote:
                                    Have you tried to test just SLSB clustering first without MDB? Check out the example there.
                                    http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossHA


                                    I've done this - instead of calling the SLSB from the MDB (in my basic test example I linked to earlier), I'm calling it from the servlet.... round-robining of the SLSB still doesn't work; I'm only creating the remote interface once, and then calling the method on it repeatedly...

                                    Any further ideas as to where I should look?


                                    I suspect it is just some setup problem. But if you are really pressed for time for production, you should consider subsribe to JBoss support.

                                    OT:
                                    I'm trying to push my boss in that direction :)
                                    We've already gone into production, but i'd still like to get this working in time for the next revision :)

                                    1 2 Previous Next