Proxy-Based Load Balancing
2 min read
2 min read
2 min read
2 min read
2 min read
2 min read
2 min read
2 min read
3 min read
A proxy to a replicated object can distribute its invocations over the replicas: a direct proxy holds the endpoints of the replicas, and an indirect proxy gets them from the locator. Locator Semantics for Clients describes load balancing with a locator.
Load Balancing with Connection Caching
By default, a proxy caches its connection and uses the Random endpoint selection type. On the first invocation, Ice reuses an existing connection to any of the proxy's endpoints, including one opened by another proxy; otherwise, it tries the endpoints in random order until it establishes a connection to one of them. The proxy then sends all its invocations over this connection until the connection closes, so the proxies of a communicator that hold the same endpoints typically reach the same server.
With the Ordered endpoint selection type, Ice tries the endpoints in the order they appear in the proxy, and still reuses an existing connection to any of them first.
Per-Request Load Balancing
When a proxy does not cache its connection, Ice selects an endpoint for each invocation, and uses an existing connection to this endpoint or connects to it. With the Random endpoint selection type, successive invocations can therefore reach different servers, though not necessarily in equal numbers:
GreeterPrx proxy{ communicator, "greeter:tcp -h 10.0.0.1 -p 4061:tcp -h 10.0.0.2 -p 4061"};proxy = proxy.ice_connectionCached(false);var proxy = GreeterPrxHelper.createProxy( communicator, "greeter:tcp -h 10.0.0.1 -p 4061:tcp -h 10.0.0.2 -p 4061");proxy = GreeterPrxHelper.uncheckedCast(proxy.ice_connectionCached(false));var proxy = GreeterPrx.createProxy( communicator, "greeter:tcp -h 10.0.0.1 -p 4061:tcp -h 10.0.0.2 -p 4061");proxy = proxy.ice_connectionCached(false);let proxy = new VisitorCenter.GreeterPrx( communicator, "greeter:tcp -h 10.0.0.1 -p 4061:tcp -h 10.0.0.2 -p 4061");proxy = proxy.ice_connectionCached(false);proxy = GreeterPrx(communicator, 'greeter:tcp -h 10.0.0.1 -p 4061:tcp -h 10.0.0.2 -p 4061');proxy = proxy.ice_connectionCached(false);$proxy = GreeterPrxHelper::createProxy( $communicator, 'greeter:tcp -h 10.0.0.1 -p 4061:tcp -h 10.0.0.2 -p 4061');$proxy = $proxy->ice_connectionCached(false);proxy = VisitorCenter.GreeterPrx( communicator, "greeter:tcp -h 10.0.0.1 -p 4061:tcp -h 10.0.0.2 -p 4061")proxy = proxy.ice_connectionCached(False)proxy = GreeterPrx.new(communicator, "greeter:tcp -h 10.0.0.1 -p 4061:tcp -h 10.0.0.2 -p 4061")proxy = proxy.ice_connectionCached(false)var proxy = try makeProxy( communicator: communicator, proxyString: "greeter:tcp -h 10.0.0.1 -p 4061:tcp -h 10.0.0.2 -p 4061", type: GreeterPrx.self)proxy = proxy.ice_connectionCached(false)With the Ordered endpoint selection type, each invocation goes to the first endpoint, and to the next ones only when Ice cannot connect to the first. Ice does not remember a failed connection attempt: while the first server is unavailable, every invocation starts with an attempt to connect to it.