1 2 Previous Next 25 Replies Latest reply on Oct 19, 2012 11:31 AM by Justin Bertram

    HA & LoadBalancing

    Leonid GL Newbie

      My cluster consists of servers A and B running on different machines. The server A has a backup server C (shared store) running on the same machine. Each server has a ConnectionFactory bound to its jndi. My test client uses pure jms-api.

       

       

      The problem is, when I download the ConnectionFactory from the live server (A) and create a connection Object, the connection will be established to server B. The next, newly created connection works properly and is bound to the server A. Seems like the Client-Side load balancing, but this feature is not activated.

       

      This strange behavior goes away if I deactivate the HA (<ha>false</ha>) in the ConnectionFactory of sever A.

       

      All HQ-Servers are of version 2.2.14.Final running within JBoss 6.1.

       

      Thank you.

        • 1. Re: HA & LoadBalancing
          Andy Taylor Master

          looks like you have a configuration problem, server A is announcing the server B's connector as its connector, check this is correct in the config

          • 2. Re: HA & LoadBalancing
            Leonid GL Newbie

            Thank you for quick reply

             

            The configuration seems to be right. The nodes A and B will be conencted to each other. But you could have a look.

             

            Server A:

             

            <connectors>

                  <connector name="netty">

                     <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>

                     <param key="host"  value="172.20.66.201"/>

                     <param key="port"  value="${hornetq.remoting.netty.port}"/>

                  </connector>

            </connectors>

            ---------------------------------------

            <acceptors>

                  <acceptor name="netty">

                     <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>

                     <param key="host"  value="172.20.66.201"/>

                     <param key="port"  value="${hornetq.remoting.netty.port}"/>

                  </acceptor>

            </acceptors>

             

            The same for Server B but with its IP. The broadcast-group and discovery-group settings are default and equal for all servers.

             

            ConnectionFactorys of all servers:

             

            <connection-factory name="NettyConnectionFactory">

              <ha>true</ha>

                  <connectors>

                       <connector-ref connector-name="netty"/>

                  </connectors>

                  <entries>

                       <entry name="/ConnectionFactory"/> 

                 </entries>

             

            <failover-on-server-shutdown>true</failover-on-server-shutdown>

            <consumer-window-size>0</consumer-window-size>

            <client-failure-check-period>4000</client-failure-check-period>

            <connection-ttl>8000</connection-ttl>

            <reconnect-attempts>3</reconnect-attempts>

            <confirmation-window-size>1048576</confirmation-window-size>

            </connection-factory>

             

             

            The jboss servers are startet using:

             

            run -c [conf] -b 0.0.0.0

             

            • 3. Re: HA & LoadBalancing
              Andy Taylor Master

              sorry i misread your post, you say

               

              The problem is, when I download the ConnectionFactory from the live server (A) and create a connection Object, the connection will be established to server B. The next, newly created connection works properly and is bound to the server A. Seems like the Client-Side load balancing, but this feature is not activated.

              What do you mean it is not activated? if you use HA then it will load balance

              • 4. Re: HA & LoadBalancing
                Leonid GL Newbie

                What do you mean it is not activated? if you use HA then it will load balance

                To activate the client-side loadbalancing the ConnectionFactory should look like:

                 

                 

                <connection-factory name="ConnectionFactory">

                   <discovery-group-ref discovery-group-name="my-discovery-group"/>

                 

                   <entries>

                      <entry name="ConnectionFactory"/>

                   </entries>

                 

                   <connection-load-balancing-policy-class-name>

                       org.hornetq.api.core.client.loadbalance.RandomConnectionLoadBalancingPolicy

                   </connection-load-balancing-policy-class-name>

                </connection-factory>

                 

                 

                Each connection object created by this factory is connected to a different cluster-node.

                 

                Otherwise each connection is bound to the same node. Am I right?

                 

                You can see on my previous post that the ConenctionFactory neither refers a discovery group nor defines the balancing policy. It means my Client should (but it is not the case) send always to the same server. The message balancing undertakes the server.

                • 5. Re: HA & LoadBalancing
                  Andy Taylor Master

                  No, like i say all HA connection factories are load balanced, connection-load-balancing-policy-class-name just lets you choose the policy, its round robin by default

                  1 of 1 people found this helpful
                  • 6. Re: HA & LoadBalancing
                    Leonid GL Newbie

                    like i say all HA connection factories are load balanced

                    Strange that the <ha>true</ha> automatically activates the factory loadbalancing. If the administrator doesn’t define the <discovery-group-ref> in the factory, he actually wants the clients which lookup this factory, to connect to THIS node (and its backup) and not to some other in the cluster…

                     

                    I have spent much time reading the hq-manual, but I can’t remember the pages talking about it.

                     

                    Is there an opportunity to deactivate the factory loadbalancing?

                    • 7. Re: HA & LoadBalancing
                      Andy Taylor Master

                      Strange that the <ha>true</ha> automatically activates the factory loadbalancing.

                      yes HA = high availibilty = load balanced

                       

                      set HA = false if you dont want load balanced

                      • 8. Re: HA & LoadBalancing
                        Leonid GL Newbie

                        yes HA = high availibilty = load balanced

                        The <ha>true</ha> in a connection factory means “activate the failover”; go to backup if live is died.

                         

                        What has it to do with the connection loadbalancing?

                         

                        I don’t understand why my connctionfactory, which doesn’t refer a discovery group, creates connections to some other cluster nodes.

                        • 9. Re: HA & LoadBalancing
                          Andy Taylor Master

                          High availibilty means connections created by a connection factory can connect to any node in a cluster, i.e. no matter what the status of a node, a connection factory that is HA makes all nodes available (hence HA) to the client.

                          1 of 1 people found this helpful
                          • 10. Re: HA & LoadBalancing
                            Leonid GL Newbie

                            OK. However, the client doesn't switch to the backup if <ha> is false. It just fails.

                             

                            Where is the difference between <ha>true</ha> and <discovery-group-ref/> in a connection factory? Both have the same purpose - to make all nodes available.

                            • 11. Re: HA & LoadBalancing
                              Andy Taylor Master

                              OK. However, the client doesn't switch to the backup if <ha> is false. It just fails.

                              you probably have a configuration issue, i would start by making sure the clustered/ha examples work.

                               

                              Where is the difference between <ha>true</ha> and <discovery-group-ref/> in a connection factory? Both have the same purpose - to make all nodes available.

                              discovery group has nothing to do with HA, its just a way of discovering a server, that server could be a single server or a server within a cluster, it makes no difference, i.e. find me a server. HA means once i have connected to the server give me the full topology (i.e. all live and backups) of the cluster and allow me to connect to anyone available.

                              • 12. Re: HA & LoadBalancing
                                Leonid GL Newbie

                                OK. However, the client doesn't switch to the backup if <ha> is false. It just fails.

                                you probably have a configuration issue, i would start by making sure the clustered/ha examples work.

                                I carried out the /jms/multiple-failover example (hornetq-2.2.14.Final). All works like it should - live an backup start, the server2 waits. Over all the example ends successfully. Then I commented out the <ha>true</ha> in con-factory in the server0 and started again. After killing server0, the server1 becomes live and nothing hapens! The client doesn't switch to backup;it can't ack the messages.

                                • 13. Re: HA & LoadBalancing
                                  Andy Taylor Master

                                  I carried out the /jms/multiple-failover example (hornetq-2.2.14.Final). All works like it should - live an backup start, the server2 waits. Over all the example ends successfully. Then I commented out the <ha>true</ha> in con-factory in the server0 and started again. After killing server0, the server1 becomes live and nothing hapens! The client doesn't switch to backup;it can't ack the messages.

                                  thats exactly what i would expect

                                  • 14. Re: HA & LoadBalancing
                                    Leonid GL Newbie

                                    Sorry but I can’t follow you. In your previous post you said that I should check my configuration because my client doesn’t switch to backup if the <ha> is false. In other words, a correct configuration should allow the client to connect to backup regardless of <ha> true or false.

                                     

                                    Now you post that is what you would expect…

                                    1 2 Previous Next