10 Replies Latest reply on Mar 1, 2006 5:01 AM by Susitha Bandara

    EJB and Http load balancing

    Susitha Bandara Newbie

      Dear all,
      Let me know when we have stateless session bean do we need to do both EJB and http load balancing.

      http://wiki.jboss.org/wiki/Wiki.jsp?page=HTTPLoadbalancer doesn't explain it well. Also i need to what is the Hosts lists is. Is it the hosts in the cluster or the clients. (I think it should be the cluster's hosts)

        • 1. Re: EJB and Http load balancing
          Brian Stansberry Master

          Do you have a web app? The wiki page you reference is talking about a webapp load balancer.

          Suggest you start with the Clustering docs. http://docs.jboss.org/jbossas/clustering/JBossClustering7.pdf

          • 2. Re: EJB and Http load balancing
            Susitha Bandara Newbie

            Thanks for the quick reply. I have already gone through the Clustering7 manual.
            First I built a simple EJB (stateless session bean) which includes a business logic of "Fibonacci number" generator. First I tested it and worked well. Then I added " true "in the jboss.xml (and also <cluster-config> etc ).
            Then I made a request from a client machine (in the LAN) by putting a big number, (which will take a long time to process) and while it's being processed I stopped the server.
            But unfortunately the "connection refused" popup came. I had three machines in the cluster and i've deployed in the farm folder. But that cluster nodes didn't serve when the server failed. That means failover didn't work and l've tested for load balancing as well; it also failed.
            Please let me know if i skipped some steps or the correct order. Because "CLUSTERING 7" doesn't provide details more than this.

            • 3. Re: EJB and Http load balancing
              luong duy Newbie

              I have same problem with you. In case of HA-RMI it have message

              Caused by: java.rmi.RemoteException: Service unavailable.
               at org.jboss.ha.framework.interfaces.HARMIClient.invokeRemote(HARMIClient.java:184)
               at org.jboss.ha.framework.interfaces.HARMIClient.invoke(HARMIClient.java:238)
               ... 2 more

              anybody help us ?

              • 4. Re: EJB and Http load balancing
                Brian Stansberry Master


                What you wrote sounds like you're on the right track; no need for loadbalancer webapp.

                1) You mention adding a cluster-config to jboss.xml. Not needed if you're using the DefaultPartition and standard loadbalance policies. Just pointing that out in case there's a problem there.

                2) Are you certain that your servers have formed a cluster? Your logs should show something like this, where the last bit lists the 3 machines:

                2006-02-22 13:09:52,765 INFO [org.jboss.ha.framework.interfaces.HAPartition.lifecycle.DefaultPartition] New cluster view for partition DefaultPartition (id: 1, delta: 1) : [,]

                3) Also, did the EJB properly deploy on all 3 nodes?

                • 5. Re: EJB and Http load balancing
                  luong duy Newbie

                  i found that althought i config deploy stateless session bean in clustered mode . But JBoss still load "invoker-proxy-binding" with name "stateless-rmi-invoker" which no "HA" is applied. And i try to reconfig "stateless-rmi-invoker" which "HA" is applied Jboss do load balance and fail over with no error

                  When i shut down one node and restart it this can not sync state with other nodes. And Tree Cache in restarted node tell that this node is first node in partition ?????

                  • 6. Re: EJB and Http load balancing
                    Susitha Bandara Newbie

                    Thanks again.
                    I'm having the problem with the central node of the cluster. As i think the cluster should be seen as a single machine to the outside world. In order to achieve this I believe we need something like a "cluster manager" in Oracle (i think here it is the dispatcher). The CODE that i got is very similar to the code you've sent. i.e.


                    10:52:22,135 INFO [DefaultPartition] Number of cluster members: 2

                    10:52:22,145 INFO [DefaultPartition] Other members: 1

                    10:52:22,155 INFO [DefaultPartition] Fetching state (will wait for 30000 milliseconds):

                    10:52:22,175 INFO [DefaultPartition] New cluster view for partition DefaultPartition: 9 ([,] delta: 0)

                    10:52:22,205 INFO [DefaultPartition] I am (null) received membershipChanged event:

                    10:52:22,205 INFO [DefaultPartition] Dead members: 0 ([])

                    10:52:22,215 INFO [DefaultPartition] New Members : 0 ([])

                    10:52:22,225 INFO [DefaultPartition] All Members : 2 ([,])

                    10:52:23,597 INFO [HANamingService] Listening on /

                    10:52:23,627 INFO [DetachedHANamingService$AutomaticDiscovery] Listening on /, group=23

          , HA-JNDI address=

                    • 7. Re: EJB and Http load balancing
                      Brian Stansberry Master

                      This log snippet answers my point #2 above; your two cluster nodes are seeing each other and forming a cluster.

                      How about points #1 and #3?

                      • 8. Re: EJB and Http load balancing
                        Susitha Bandara Newbie

                        The other points are ok. That is I used defaultpartion and didn't make any configuraions there. I just made only "/=ture". I think that means i'm using default loadbalancing and failover policies.

                        I deployed the ejb in the farm folder. Then it appeared in all the nodes in the cluster. (Also it worked in each node when i made seperate requests for each cluster.)
                        Now the problem i'm having is the configuring (or simetimes building) the dispatcher. As i understood it should have something called client code which downloads to the client at initial state. So i need to know more about this client code and a sample code. (since i didn't get it in the "Clustering 7" document.)

                        • 9. Re: EJB and Http load balancing
                          Brian Stansberry Master

                          The "code that downloads to the client" is simply a) the EJB home proxy you obtain by doinga HA-JNDI lookup or b) the EJB proxy that is returned when you invoke create() on the home.

                          You said load balancing didn't work. How did you test that (in detail)?

                          Your Fibonacci number test is not a good failover test. Once a request has successfully reached a server and been invoked on it, if there is a failure during processing the client proxy is not going to transparently retry on another server -- it's going to throw an exception. The proxy has no way of knowing if retrying is the correct thing to do once it knows the method was invoked on the server. Only your application can make that decision.

                          • 10. Re: EJB and Http load balancing
                            Susitha Bandara Newbie

                            The way i tested the load balancing is, I made several requests for the cluster and put large numbers to calculate in each of the browser instances.
                            Then I checked the CPU usage of each node. Then node that we made the original request exhibited 100% of cpu usage and others didn't show any significant change.
                            So we assumed that load balancing didn't happen.
                            I realized that fibonacci is not a good one to test load balancing after your guidance and if you could please suggest a suitable thing.