Home Help Center

Load Balancing between Glacier2 routers

Nis BaggesenNis Baggesen Member ✭✭✭
Ok, so we have Y clients and X different server processes which all need to communicate.

In an simple world they would just have proxies pointing directly at each other and everything would be swell.

However to protect the servers, and to simplify navigating through NATs etc. all outside connections are routed using a Glacier2 router.

All well and good, but it seems to me that this creates a sort of bottleneck as all traffic will routed back and forth through the Glacier2 router.

So how would I go about balancing load and handling faults in the routers. I assume that I can at the very least setup several routers and provide the clients with a list of possible endpoints for the routers, and then let them randomise their initial connection. But I was wondering if there was some other options I've overlooked, that might provide better balacing, migrations of sessions etc.

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    I don't think you overlooked any options. To balance the load of your clients, you should deploy multiple Glacier2 routers and you should provide your clients a proxy with multiple endpoints for the Glacier2 router.

    Once a client has established a session with a given router, it will exclusively use this router. There's no mechanism to migrate a session to another router. If there's a fault in a router (software or hardware problem), all the sessions handled by the router will be lost and the client will need to re-establish a session with another router.

    Benoit.
  • Nis BaggesenNis Baggesen Member ✭✭✭
    Ok. At least my intuition was right.

    Just one more question then. My client also acts as a server in order to handle push-updates from the server. In order to do so it needs to have a router configured for its own adapter. Presumably this router has to be the same router as the outgoing router set up for the clients communicator. But, if i understand correctly, if a proxy specifies multiple endpoints the actual endpoint we use is selected at random, so how do I make sure the adapter and the communicator use the same router endpoint ? Should I avoid initialising them through configuration properties, and do it in code instead?

    I don't know if that was all clear. In any case you've answered my main question, so i think I can figure out the rest from here.
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    If you use a router, then your object adapter doesn't need to be configured with any endpoints. Instead, the object adapter will use the connection that has been established from the client to the router to dispatch requests (i.e., the connections are used bi-directional).
  • Nis BaggesenNis Baggesen Member ✭✭✭
    marc wrote:
    If you use a router, then your object adapter doesn't need to be configured with any endpoints. Instead, the object adapter will use the connection that has been established from the client to the router to dispatch requests (i.e., the connections are used bi-directional).


    Yes, but doesn't it need to have an adapter specific router setup to enable callbacks ?

    Like in your callback demo example where you setup both

    Ice.Default.Router=Glacier2/router:ssl -p 10005

    and

    Callback.Client.Router=Glacier2/router:ssl -p 10005

    It's these router endpoints I was concerned about.
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    Yes, this is correct. I thought you meant regular endpoints.

    With Glacier2, your code usually looks something like this:
    Ice::RouterPrx routerBase = communicator()->getDefaultRouter();
    if(!routerBase)
    {
        // Error message that says that Ice.Default.Router is not set
    }
    
    Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(routerBase);
    if(!router)
    {
        // Error message that says that the configured router is not a Glacier2 router
    }
    
    // Establish session with the Glacier2 router (see chat demo in Connections)
    
    Ice::ObjectAdapterPtr adapter = ... ; // Create OA (no endpoints required)
    
    adapter->addRouter(router); // Add the router to the OA
    

    Of course you can also use configuration properties, but with the code above, you have to specify the router proxy only once.
Sign In or Register to comment.