4 Replies Latest reply on Jan 11, 2007 8:01 AM by Young LI

    Load balance policy problem

    Young LI Newbie

      We have an application where we need to customize JBoss LoadBalancePolicy. What we have found is that JBoss gives erroneous target information upon restart of server instances in a cluster. Our setup is as follows:

      - JBoss version: 4.0.3SP1
      - OS: Windows XP
      - cluster: 2 server instances
      - custom load balance policy (LBP): a simple class implementing LoadBalancePolicy. When the count of available targets changes, randomly chooses a target.

      Initially, both server instances are started, the printout from our custom LBP is as follows:
      Tue Jan 09 10:46:35 EST 2007 TARGET COUNT: 2
      which is good.
      Then, I stopped one server instance, and the printout is as follows:
      Tue Jan 09 10:46:57 EST 2007 TARGET COUNT: 1
      which is good too.
      Then I started the server instance, and the printout is as follows:
      Tue Jan 09 10:47:57 EST 2007 TARGET COUNT: 2
      Tue Jan 09 10:47:57 EST 2007 TARGET COUNT: 1
      Tue Jan 09 10:48:03 EST 2007 TARGET COUNT: 2
      Our LBP's chooseTarget method was called with the right number of targets, and then wrong number of targets(1), and then the right number of targets again.
      Further, after I restarted the server instances several times, the target count started changing back and forth between 1 and 2.

      What is wrong? Thanks for your input in advance.

        • 1. Re: Load balance policy problem
          Brian Stansberry Master

          Any possibility there is a call failure when you invoke on one of the servers, such that the client proxy is failing over to the other server?

          You could then see a pattern where the client sees there are 2 servers, contacts one, the call fails so the client removes the server from the target list, contacts the other server, call succeeds but server sees the client target list is out of sync with the server, so it reestablishes the 2 targets, etc.

          • 2. Re: Load balance policy problem
            Young LI Newbie

            Thanks for your response. I forgot to mention some application details. We have two SLSBs, ejb1 and ejb2, in a cluster of two server instances. In my test, I first lookup home objects and create one ejb1 instance and one ejb2 instance. Then an infinite loop is entered where a simple method is called on ejb1 and thenn on ejb2. At the same time, server one is stopped. My custom load balance policy for ejb2 is first called with 2 targets, then with 1, while custom load balance policy for ejb1 is called with 1 correctly.

            In a second test, I created only ejb1, and my custom load balance policy is called with the right number of targets after server stop/restart.

            Is there a way to avoid the wrong number of targets in custom load balance policy?

            • 3. Re: Load balance policy problem
              Brian Stansberry Master

              So in the first test, while one of the servers is down, ejb2 is cycling back and forth between 2 targets and one target?

              • 4. Re: Load balance policy problem
                Young LI Newbie

                ejb2 LBP was called with 2 then 1 and stayed with 1. This was the behavior for one server stop/restart. I have observed in our UAT env that some ejb LBP was cycling back and forth between 1 and 2 after restarting server instances in a round-robin fashion several times. I.e. the number of targets kept alternating between 1 and 2 when both server instances were up.