4 Replies Latest reply on Apr 18, 2011 12:43 PM by Wolf-Dieter Fink

    a question about EJB3 load balance

    Joseph Wu Newbie

      Hi all,

       

           I started learning EJB3 recently and I am having a question about EJB session bean load balancing in jboss AS cluster.suppose I have 3 physical machines configured as a cluster.I deployed a simple ejb app with a statless session bean and a statful session bean,both with @Remote annotation.The 3 jboss instances are all listencing on same standard ejb port,their ip are 192.168.0.1\2\3

       

      question is ,if I developed an standalone EJB client app and query ejb from 192.168.0.4 which is another jvm differs from above 3

      1) which ip should I point to? any one in 192.168.0.1\2\3 would do? or a hardware balancer ip ?

      2) who is responsible for the load balancing ? and how does it acheive ?a hardware balancer? the ejb container? or some ejb built in mechanism ?

      3) if node A was down,how does the state in statful session bean transfer to other node?how does it gurantee?

       

       

      sorry for my possible wrong spelling and thank you very much

        • 1. a question about EJB3 load balance
          Wolf-Dieter Fink Master

          If you add @Clustered to your SLSB the JBoss ejb client is aware to the cluster and load balance your requests.

           

          You have to check:

          - the servers are building a cluster (see logfile for 'No of Members' messages during start)

          - The client should use a JNDI-HA port (it's 1100 instead of 1099 by default)

          - The client should use a InitialContext with '192.168.0.1:1100,192.168.0.2:1100' to be failsave during first lookup

          - The client should use the same RemoteIF during the whole lifetime

           

          1) as I wrote one/more/all separated by ',' or use autodiscover by multicast

          2) no hw-lb necessary

          3) You have to configure BUddy-Replication for this (but think about performance vs. failover, often it is aceptable to have seldom failures by this )

          • 2. a question about EJB3 load balance
            Joseph Wu Newbie

            thank you very much Wolf-Dieter Fink ,it is very helpful.I have something to make clear based on your answers:

             

            1) by "multicast/auto discovery ", do you mean to write client code to catch network multicast event from cluster and build connection with ejb app in cluster? any tutorial url ?

            2) "BUddy-Replication" means session bean replication among cluster nodes,right ?

            3) suppose I was building a tx critical system, any production best practice experience ?

             

             

            that is all, thank you very much

            • 3. Re: a question about EJB3 load balance
              Joseph Wu Newbie

              sorry, I got answers  for Q1 and Q2 after a google walk

               

              http://docs.jboss.org/jbossas/jboss4guide/r4/html/cluster.chapt.html for Q1 and Q2

              1) by "multicast/auto discovery ", do you mean to write client code to catch network multicast event from cluster and build connection with ejb app in cluster? any tutorial url ?

              2) "BUddy-Replication" means session bean replication among cluster nodes,right ?

               

               

              but no luck for Q3,any idear ?

              3) suppose I was building a tx critical system, any production best practice experience ?

              • 4. a question about EJB3 load balance
                Wolf-Dieter Fink Master

                Transaction might be a problem.

                If you did not use UserTransactions (you better remove the UTx service from deployment ) it will be simply,

                avoid Remote invocations across the Cluster members, it will be a good idea for performance as well )

                 

                The transaction is handled by one JBoss instance, persistent data use a transactional cache (flushed after commit/rollback).

                 

                If you use UTx you are in trouble like me

                We use the TransactionStickyLoadBalancer for EJB2.1

                But with EJB3 there is no equivalent implementation ATM, there is a JIRA for this, coming hopefully soon.

                The problem is that different server become member of a transaction and might contain the same entity in different caches that are outdated!