Home Help Center

Replica Groups and conections

jaejae Member John EisenmanOrganization: Orange SVProject: N/A
I've set up a replica group with a load balancing type of Random. I have written a couple of test clients (in Python and Java) that connect to this group. The clients themselves are implemented as Ice Applications.

I can confirm that when I run a test client, it randomly selects one of the server endpoints for the connection.

I have also added a loop to the test code where it attempts to select a new proxy each time through the loop. I find that within the test client, it always connects to the same server. Is this expected? My expectation was that I could connect to a different server for load balancing reasons.

I have a replica group called, "CanonicServerGroup".

My python test code looks like this:
for r in range(repeat):
    bProxy = self.communicator().stringToProxy("[email protected]")
    boost = UrlIce.BoostPrx.checkedCast(bProxy)
    .... more code to communicate with boost ....

Section 36.9 of the Ice manual states:
IceGrid’s load balancing capability assists the client in selecting an initial endpoint for a connection. As discussed in Section 30.17.2, once a client has established a connection, all subsequent requests on the proxy that initiated the connection are sent to the same server without further consideration for load balancing.

In this case, has the connection already been established? What is the correct way to obtain a connection to a newly selected endpoint?

Comments

  • GreenhippoGreenhippo Member AlexOrganization: University of AucklandProject: Intelligent Middleware ✭✭
    Ice caches its results from registry lookups, so everytime you think you are getting a new object its just getting its cached copy

    try setting this in your config file
    Ice.Default.LocatorCacheTimeout=0
    
  • jaejae Member John EisenmanOrganization: Orange SVProject: N/A
    Thanks. I set Ice.Default.LocatorCacheTimeout=0 for my client and now see all servers being used at random. In practice, I assume that we might set this to some number of seconds. Is this the proper way to achieve the result that I want?
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    Yes, if you want the load balancing to be taken care of by IceGrid, you need to set a low locator cache timeout to ensure that the client will regularily contact the IceGrid locator to retrieve new endpoints for the proxy.

    Another possibility is to configure the replica group to return multiple endpoints and set a higher locator cache timeout to avoid contacting the IceGrid locator too often. The load balancing will then be done locally by the Ice runtime by selecting at random one of the endpoints associated to the proxy.

    Note that you also need to configure the proxy with ice_connectionCached(false) to ensure that connections aren't cached with the proxy (see the Ice manual for more information). You can also configure the locator cache timeout on a per proxy basis.

    So I would do the following:
        const int timeout = 
        bProxy = self.communicator().stringToProxy("[email protected]")
        bProxy = bProxy.ice_connectionCached(false);
        bProxy = bProxy.ice_locatorCacheTimeout(60); // 60 seconds
        boost = UrlIce.BoostPrx.checkedCast(bProxy)
    for r in range(repeat):
        .... more code to communicate with boost ....
    

    Cheers,
    Benoit.
  • jaejae Member John EisenmanOrganization: Orange SVProject: N/A
    "Broadcast" to all members of a replica group?

    Thanks for the above information; it was just what I needed.

    I have related question. I have some functions that I'd like to call for all members of a replica group. As you mention, IceGrid can return all members of a replica group; how can I gain access to this information and call the same function on each?
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    You can retrieve the proxy of each individual replica with the IceGrid::Query::findAllReplicas method (introduced in Ice 3.2). Let us know if you need more information!

    Cheers,
    Benoit.
  • jaejae Member John EisenmanOrganization: Orange SVProject: N/A
    Sounds like another reason to move to 3.2.

    My project is currently running 3.1 (and won't be upgrading right away). Is there also a solution under 3.1?

    -John
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    You could register a well-known object with the adapter descriptor. This well-known object would be registered with a given type which would be used to retrieve the proxies of each object with the IceGrid::Query::findAllObjectsByType method.

    Cheers,
    Benoit.
Sign In or Register to comment.