Archived

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

Cannot get IceGrid round robin to work

Hi, Im having trouble getting the load balancing policy on my replica groups for my grid application to work as i think it should. What i want is that every other call i make on an "A" replica will be to SC_A_1, with the other going to SC_A_2 on the other node.

Here is a sample of the grid file im using for my app - we run 2 "A" servers and 2 "B"s. Ive removed the spurious java options/parameters for clarity.
<icegrid>
        <application name="MyProcessApplication">
	
 <replica-group id="A">
   <load-balancing type="round-robin" />
    <object identity="A" type="com::wind::MyProcess"/>    
 </replica-group>
 
  <replica-group id="B">
   <load-balancing type="round-robin"/>
    <object identity="B" type="com::wind::MyProcess"/>    
 </replica-group>
 
 <server-template id="MyProcess">
            <server id="MyProcess-${index}-DEV" activation="manual" exe="/apps/jdk1.6.0_02/bin/java" pwd="${home}">
            <option>-server</option>
            <option>MyProcess</option>
				<adapter name="MyProcessAdapter"
                        replica-group="${group}"
                    register-process="true"
                    endpoints="tcp -h ${server.ip.address}">
                </adapter>
				<property name="Ice.MessageSizeMax" value="20000"/>
            </server>
        </server-template>

        <node name="PrimaryNode">
        	<server-instance template="MyProcess" index="1" group="A" server.ip.address="12.143.29.120" name="SC_A_1"/>
        	<server-instance template="MyProcess" index="3" group="B" server.ip.address="12.143.29.120" name="SC_B_1" />            
        </node>
        
        <node name="SecondaryNode">
        	<server-instance template="MyProcess" index="2" group="A" server.ip.address="12.143.29.120" name="SC_A_2" />
        	<server-instance template="MyProcess" index="4" group="B" server.ip.address="12.143.29.120" name="SC_B_2" />
        </node>

        </application>
</icegrid>


My client code is
<CODE>
ObjectPrx prx = communicator.stringToProxy("A");
this.proxy = MyProcessPrxHelper.uncheckedCast(prx);
for (int i = 0; i < LOOPS; i++) {
logger.info("i: " + i + + " - " + proxy.getName());
}
</CODE>

Im expecting each call on the proxy to round robin e.g SC_A_1, SC_A_2, SC_A_1 etc. But i find it always invokes on SC_A_1 or SC_A_2 but every call then invokes on the same server.

Any ideas/advice?

Comments

  • bernard
    bernard Jupiter, FL
    Hi Ian,

    What you're seeing is the expected behavior :).

    There are two default behaviors at play here:
    - by default, Ice (your client-side runtime) caches connections and prefers endpoints with an established connections to endpoints without.

    Your first call creates a connection to SC_A_1, and since this connection is established, subsequent calls to the "same" replicated object will reuse this connection.

    This behavior (and how to change it) is described in details in the "Connection Management in Ice" article in issue 24 of our newsletter.

    - by default, Ice (still the client-side runtime) also caches indirect-proxy resolution. When you resolve a well-known proxy, adapter id or replica group id, Ice keeps the result in its "locator cache".

    With your current replica-group definition, n-replicas is 1 (the default), so each resolution returns the endpoint(s) for a single object adapter. That's probably what you want. However, you don't want to use the same object adapter over and over--you want your client runtime to resolve the well-known proxy for each call, i.e. ask IceGrid for the next object-adapter in its round-robin list. You can do so by disabling the locator cache in your client:

    Ice.Default.LocatorCacheTimeout=0

    See http://www.zeroc.com/doc/Ice-3.3.0b/manual/Adv_server.29.17.html
    and http://www.zeroc.com/doc/Ice-3.3.0b/manual/PropRef.46.8.html for further details.

    Best regards,
    Bernard