[jboss-user] [Clustering/JBoss] - Clustering and load balancing EJB 2.x

itchy75 do-not-reply at jboss.com
Mon Jul 30 14:25:40 EDT 2007


Hi,

I launch 2 Jboss servers (4.0.5) in cluster and I want to load balance the ejb calls between the two servers. I read the documentation and I created a cluster-service.xml and I modified my ejb configuration as follow : 

Part of cluster-service.xml 


  | <mbean code="org.jboss.ha.jndi.HANamingService"
  |         name="jboss:service=HAJNDI">
  |      <!-- We now inject the partition into the HAJNDI service instead
  |           of requiring that the partition name be passed -->
  |      <depends optional-attribute-name="ClusterPartition"
  |         proxy-type="attribute">jboss:service=${jboss.partition.name:DefaultPartition}</depends>
  |      <!-- Bind address of bootstrap and HA-JNDI RMI endpoints -->
  |    <attribute name="BindAddress">${jboss.bind.address}</attribute>
  |    <!-- RmiPort to be used by the HA-JNDI service
  |         once bound. 0 => auto. -->
  |    <attribute name="RmiPort">0</attribute>
  |    <!-- Port on which the HA-JNDI stub is made available -->
  |    <attribute name="Port">1100</attribute>
  |    <!-- Backlog to be used for client-server RMI
  |         invocations during JNDI queries -->
  |    <attribute name="Backlog">50</attribute>
  |      <!-- The thread pool service used to control the bootstrap and
  |      auto discovery lookups -->
  |      <depends optional-attribute-name="LookupPool"
  |         proxy-type="attribute">jboss.system:service=ThreadPool</depends>
  |         <!-- A flag to disable the auto discovery via multicast -->
  |      <attribute name="DiscoveryDisabled">false</attribute>
  |      <!-- Set the auto-discovery bootstrap multicast bind address. If not
  |      specified and a BindAddress is specified, the BindAddress will be used. -->
  |      <attribute name="AutoDiscoveryBindAddress">${jboss.bind.address}</attribute>
  |      <!-- Multicast Address and group port used for auto-discovery -->
  |      <attribute name="AutoDiscoveryAddress">${jboss.partition.udpGroup:230.0.0.4}</attribute>
  |    <attribute name="AutoDiscoveryGroup">1102</attribute>
  |      <!-- The TTL (time-to-live) for autodiscovery IP multicast packets -->
  |      <attribute name="AutoDiscoveryTTL">16</attribute>
  |      <!-- The load balancing policy for HA-JNDI -->
  |      <attribute name="LoadBalancePolicy">org.jboss.ha.framework.interfaces.RoundRobin</attribute>
  | 
  |    <!-- IP Address to which should be bound: the Port, the RmiPort and
  |         the AutoDiscovery multicast socket. -->
  |    <!-- Client socket factory to be used for client-server
  |         RMI invocations during JNDI queries -->
  |    <!--attribute name="ClientSocketFactory">custom</attribute-->
  |    <!-- Server socket factory to be used for client-server
  |         RMI invocations during JNDI queries -->
  |    <!--attribute name="ServerSocketFactory">custom</attribute-->
  | </mbean> 

EJB configuration : 

<jboss>
  |    <enterprise-beans>
  |        <!-- Session -->
  |        <session>
  |            <ejb-name>myBean</ejb-name>
  |            <jndi-name>myBean</jndi-name>
  |            <clustered>True</clustered>
  |            <cluster-config>
  |                <partition-name>
  |                    ${jboss.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>
  |    </enterprise-beans>
  | </jboss> 

Everything is good in the JMX console, the EJB is deployed in the two servers and available on both (check with DistributedReplicantManager->listContent()).

The client application (another jboss server) is configured to lookup into the HAJNDI service of the first server.

The problem is that the ejb calls are never balanced. Each time I call it, it runs on the first server. When I undeploy the ejb from the first server, it calls the ejb on the second server (so cluster HAJNDI works). Then I deploy again the ejb on the first server and it will always call the ejb on the first server.

I have understood that HA JNDI algorithm is something like that :
1. look for name in HAJNDI tree
2. if not found, look in local jndi tree
3. if not found, look in all cluster nodes

Is that right ?

So, where does load balancing on ejb is done ? In the EJB itself ?

I have followed all the instructions in the guide, what's wrong ? 

Thanks for help.







View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4068843#4068843

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4068843



More information about the jboss-user mailing list