Archived

This forum has been archived. Please start a new discussion on GitHub.

Load Balancing per request

Is there anyway to do random server usage per request using similar semantics as the random server selection when establising the communication channel.

It would seem pointless to timeout the connection to acheive load balancing.


Actually I found this .....

-> Ice::Object proxy = communicator->stringToProxy("demo");
proxy = proxy->ice_connectionCached(false);
proxy = proxy->ice_locatorCacheTimeout(5);

would this be expensive, if used alot.

Comments

  • benoit
    benoit Rennes, France
    Hi,

    It's slightly more expensive since for each request the proxy will need to lookup a suitable (existing) outgoing connection (because the connection is not cached anymore with the proxy). It will also cause locator lookups every 5s (you might want to increase this to reduce the number of lookups...).

    I don't think it will really matter however for most applications... so unless your application is really performance critical (in which case I would recommend to benchmark this), it should be fine.

    I recommend taking a look at Matthew's article about connection management to get a better understanding on what's really happening under the hood when these settings are set, see Issue #24 of the Ice Connections newsletter.

    Cheers,
    Benoit.
  • Thanks. I could use this as a temporary solution however I have a feeling that using IceGrid would be a better solution.

    What I have is 300K events waiting to be processed and the configuration will be 10 servers each with 8 identical servers on. This is what I want to call in a load balanced manner. My current version does not use IceGrid so I just wanted to get something quick done.

    However now that I have explained what I am doing, does IceGrid in your opinion seem the correct approach, and IceGrid supports load balancing.
  • benoit
    benoit Rennes, France
    Hi,

    Actually, IceGrid won't bring you a lot more with respect to load balancing, in terms of efficiency at least. The most efficient way to do load balancing is on the client side like you do right now: the Ice runtime selects a random endpoint within the set of proxy endpoints.

    IceGrid will provide you a lot more flexibility however for the deployment: you can easily add/remove servers without having to update/restart the clients (the clients will retrieve automatically the new set of endpoints from the locator). It will also provide you more load balancing options: round-robin and adaptive; but these options will have a higher cost as the Ice client runtime might has to consult the IceGrid registry to figure out the endpoint to use for a request.

    Cheers,
    Benoit.
  • Help with load balancing

    Hi Benoit

    I am a developer in chamate01’s team.

    I am unable to achieve Load Balancing using replication (as discussed in this post). I have even explicitly closed proxy’s connection; however I am always connecting to the same servant.

    I am attaching a demo application with this post.

    Please help me find what is missed here.

    Cheers
    Nachi
  • benoit
    benoit Rennes, France
    Hi Nachi,

    I'm afraid you found a bug :(. The random endpoint selection doesn't work for proxies with only 2 endpoints. It will work if you add an additional endpoint however, try for example with the proxy: Hello -t:tcp -h localhost -p 16000:tcp -h localhost -p 16000:tcp -h localhost -p 16001

    I will prepare and post a patch for this issue later today. Thanks for reporting this bug.

    Btw, you only need to set ice_connectionCached(false) in your test case for the load balancing to work (other settings are not useful or are already the defaults). You also don't need to close the connection explicitly: closing and re-opening the connection is expensive so it's best to keep the connections open.

    Cheers,
    Benoit.
  • Hi Benoit,

    We are using a patched ice dll. Actually you are the one who provided us the patch earlier. I will send you an email with existing patch, so you can patch it further.


    And yes you are correct, I had added the same endpoints two times and the load balancing works fine!! Thanks for your help.


    ObjectPrx objProxy = Communicator.stringToProxy("Hello -t:tcp -h localhost -p 16000:tcp -h localhost -p 16001:tcp -h localhost -p 16000:tcp -h localhost -p 16001");

    Regards
    Nachi
  • Michi not fixed this already

    Hi Benoit,

    Should this not have been fixed or is it a different issue than the one that Michi mentions in this post, http://www.zeroc.com/forums/help-center/1362-load-balancing-fault-tolerance.html.

    Either way look forward to your patch.
  • benoit
    benoit Rennes, France
    Hi Mark,

    You're right, this bug has been reported already but unfortunately we forgot to fix our mainline :( Anyway, it is fixed now and it will be included in the upcoming Ice version. I've posted the patch [thread=4423]here[/thread]. Thanks for bringing this to our attention!

    Cheers,
    Benoit.