Skip to Content
author's profile photo Former Member
Former Member

Loadbalancing, Failover

Hi,

I asked me how I can test Loadbalancing (Round-Robin or are there other implementations) and Failover. I do have a simple stateless/JPA application deployed on two instances on one machine. I have several Java Clients doing some load on the application. I watch the two instances on CPU time and I can see that one is always taking the requests, the other is nearly idle. Is this the expected behaviour?

The next question is, can I debug one instance and the other instance is still taking the requests without interuption? I tried this but it does not work, both instances are stuck in debug even only one instance is in debug mode and the other is not.

Thanks for any clarification,

regards,

Igor

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    Posted on Jan 10, 2007 at 08:58 AM

    Hi Igor,

    First of all, let me ask you what you mean by "instance"? Do you mean server nodes (e.g. server0, server1) or do you really mean instances (like JC00)? The behavior is different in these two cases.

    Regarding Failover, there is a nice demo available in the NetWeaver Developer Studio. From the Welcome page navigate to Tutorials and then Sessions Failover. Probably you can use it as a reference for your test scenarios.

    Best regards,

    Vladimir

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 09:44 AM

    Hi Vladimir,

    thanks for the answer. With instance I mean server0, server1 which result in 2 OS processes (2 JVMs). I had a look to the demo application and saw that it's a J2EE 1.4 one. Even it should not change nothing to the behaviour, I would like to use my application. It's pure stateless and just uses the maxDB. I only noticed that when I use my Java Client, in a seperate JVM (of course), all the requests are going to the same server0. server1 is nearly always idle. Maybe a WebApplication behaves different. I use P4 with my Java client.

    What about debugging, I could not see in the demonstration that it's possible to debug one instance and the other instance continue to accept the requests, is this possible?

    regards,

    Igor

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Igor,

      Concerning the P4 client: once establishing the connection via getInitialContext(), your request are not going to be loadbalanced. If you make another getInitialContext() this will be loadbalanced and connected to the other server.

      About WEB applications, yes they behave differently but only if there is no session, if a session is created for a client it is linked to one server also.

      If you need additional info about the web realisation, please notify me and I'll connect you to our web experts.

      Kind Regards,

      Nikolai Neichev

      SAP Labs Bulgaria

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 08:48 AM

    Hi Nikolai,

    thanks for your answer. I try to dig more deep 😉

    Actually I have a EJB3 complient client:

    public class TestClient {

    @EJB

    private static AperoBiRemote remoteFacade;

    public static void main(String[] args) throws Exception {

    for (int _i = 0; _i < 400; _i++) {

    List<Apero> _aperos = remoteFacade.getAllAperos();

    }

    }

    }

    I start two clients with this code in it on it's own jvm. Actually the @EJB should be replaced with InitialContext or like this at build time. When I run the two clients they both go only to one instance of the server processes. The other server process is idle? Why this? Even if I start 10 clients all are going only to one instance??

    kind regards,

    Igor

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Igor,

      I want to clarify some things about the application clients behavior.

      The statement "Actually the @EJB should be replaced with InitialContext or like this at build time" is not correct. When you are starting an application client you pass some command line parameters which are used to populate the JNDI environment. Later the application client launcher uses this JNDI environment to create an InitialContext which is used to resolve the values for all annotated resources (in your case @EJB) and these values are injected with reflection. So there is no source or bytecode modification at all. All annotations are processed runtime (actually there is an optimisation, so processing occurs only at deploy-time of the application).

      About the load balancing - I as said above the Application client service creates one InitialContext which is used for the injections and it creates a new InitialContext for every JNDI lookup within the "java:" namespace (i.e. Integer intEntry = ctx.lookup("java:comp/env/myIntEntry")) from the client's code. All of these InitialContexts use the JNDI properties provided as command line parameters, i.e. the provider URL is one and the same in all the cases.

      According to Nikolai's response these should be load balanced, but I have no idea why they are not.

      Kind regards

      Martin

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 12:49 PM

    Hi Martin,

    thanks for your clarifying eMail. I did some more tests and found out that with the web frontend using the ejb application there is a loadbalancing happening. But with the Java Client Application Front-end it's not happening? Any idea why? did you made tests using P4 and seeing the loadbalancing working? What is the difference to my Application client?

    best regards,

    Igor

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.