Archived

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

question about load-balancing

for example:
i setup 2 nodes,
each node has a demo service (implements the icebox service).
and then, i have 2 clients to access the demo service.

the two clients only query the demo service's object proxy (indirect proxy) once on initialization.
and then use the proxy repeatedly.

i suppose, client 1 gets the endpoints of node 1, client 2 gets the node 2's.

so, if client 1 do much more interactions than client 2,
the node 1 work heavily than node 2.

so what can i do to handle this situation?

my solution is:

client 1 & 2 hold both proxies of demo service from node 1 & 2,
the client now has to make interactions between the 2 proxies in turn.

but i can not get all objects by calling "findAllObjectsByType"
it only return one object.

so, is there any better solution?

Comments

  • benoit
    benoit Rennes, France
    Hi,

    The findAllObjectsByType method should return the 2 objects provided that you have registered the two objects with IceGrid. If you used a deployment descriptor to deploy your application, can you post the descriptor here? Without more information, it's impossible to say why it only returns one object.

    Another solution would be to use a replica group with no load balancing policy for the object adapters hosting your replicated object and configure the proxy to not cache the connection (with the ice_connectionCached() method, see the Ice manual for more information). With such a setup, when your client invokes on the replicated proxy, it will retrieve the endpoints of each object adapter from the replica group and will eventually open connections and invoke on all the replicas.

    Cheers,
    Benoit.
  • my deploy process

    the "DemoService" is a java IceBox service .
    in order to make it easy to understand and deploy,
    i separate descriptor into serveral xml files.

    this is the "service.demo.xml"

    <icegrid>

    <replica-group id="ReplicatedDemoAdapter">
    <load-balancing type="round-robin"/>

    <object identity="demo" type="::demo::DemoModel"/>
    </replica-group>

    <service-template id="DemoServiceTemplate">
    <parameter name="name"/>

    <service name="${name}" entry="demo.DemoService">
    <adapter name="${service}" register-process="true" replica-group="ReplicatedDemoAdapter"/>

    <properties>
    <property name="Identity" value="demo"/>
    </properties>
    </service>

    </service-template>

    </icegrid>

    and then, i install the "demo" object into 2 node2,
    below is "icebox.node1.xml"


    <icegrid>

    <node name="node1">

    <icebox id="icebox1" exe="java" activation="on-demand">
    <option>-ea</option>
    <option>IceBox.Server</option>

    <service-instance template="DemoServiceTemplate" name="DemoService1"/>
    </icebox>

    </node>

    </icegrid>

    now, icebox.node2.xml comes here:

    <icegrid>

    <node name="node2">

    <icebox id="icebox2" exe="java" activation="on-demand">
    <option>-ea</option>
    <option>IceBox.Server</option>

    <service-instance template="DemoServiceTemplate" name="DemoService2"/>
    </icebox>

    </node>

    </icegrid>

    at last, the application.2nodes.xml

    <icegrid>

    <application name="application.demo">

    <include file="service.demo.xml"/>

    <include file="icebox.node1.xml"/>
    <include file="icebox.node2.xml"/>

    </application>

    </icegrid>


    then, run 2 icegridenode (one with icegridregistry),

    finally, load the application:
    icegridadmin --Ice.Config=config.demo -e "application add 'application.demo.xml'"
  • benoit
    benoit Rennes, France
    If you use the findAllObjectsByType method and do your own load balancing, you shouldn't define the replica group in the deployment descriptor and you should register the object with the adapter instead of the replica group (that's why you only get one proxy from findAllObjectsByType right now).

    For example:
    <service name="${name}" entry="demo.DemoService">
      <adapter name="${service}" register-process="true">
        <object identity="${server}" type="::demo::demoModel"/>
      </adapter>
      <properties>
        <property name="Identity" value="${server}"/>
      </properties>
    </service>
    

    The other solution I mentioned in my first post is to use the replica group and configure the proxy to not cache the connection and eventually query the locator more often, for example:
        Ice::Object proxy = communicator->stringToProxy("demo");
        proxy = proxy->ice_connectionCached(false);
        proxy = proxy->ice_locatorCacheTimeout(5);
    

    Here, invocations on this proxy will be be sent to one of the replica from the replica group and the Ice runtime will get every 5 seconds a new replica from the locator (according to the load balancing policy of the replica-group, in your case round-robin).

    Cheers,
    Benoit.
  • thank you benoit.

    and i think, if i don't use replica-group, that's no difference between Ice.3.x and Ice.2.x.
    actually, i have done this on Ice.2.1.2, it works well.

    but the new question is:
    does the indirect proxy support fail over without replica-group?

    about the connection cached, thank you for your suggestion, i will read the manual again.
  • benoit
    benoit Rennes, France
    If the objects are registered with the object adapter, not the replica group, their proxies retrieved with findAllObjectsByType will point to each individual object.

    So if the server hosting one of the object isn't available or reachable, invocations on the proxy will raise an exception, it won't automatically failover to use another replica.

    You should use a replica group if you want automatic failover.

    Cheers,
    Benoit.