Proxies to Replicated Objects
4 min read
4 min read
4 min read
4 min read
4 min read
4 min read
4 min read
4 min read
4 min read
A replicated Ice object is hosted by several servers, the replicas, each with a servant for the object's identity. A client reaches any of these replicas with one of the following proxies:
- An indirect proxy with a replica group ID.
- A direct proxy that lists the endpoints of all the replicas.
- A direct proxy with a single endpoint that points to a TCP load balancer in front of the replicas.
- A direct proxy with a single endpoint with a host name that resolves to the address of each replica.
Using an Indirect Proxy
An indirect proxy can refer to a replica group rather than to a single object adapter:
hello @ HelloGroupThe locator returns the endpoints of one or more of these replicas, and Ice connects to one of them. With IceGrid, the replicas are the object adapters of a replica group. With IceDiscovery, they are the object adapters that share this replica group ID.
Listing the Endpoints of Every Replica
A proxy can hold one endpoint for each replica:
hello:tcp -h 10.0.0.1 -p 4061:tcp -h 10.0.0.2 -p 4061Ice picks one of these endpoints and connects to it, as described in Connection Establishment. By default, the proxy then uses this connection, and therefore this replica, for all its invocations until the connection closes. Proxy-Based Load Balancing shows how to distribute the invocations across the replicas.
Adding or removing a replica means updating every proxy that lists the endpoints.
Using a TCP Load Balancer
An endpoint can point to a TCP load balancer that forwards each connection to one of the replicas:
hello:tcp -h lb.example.com -p 4061The load balancer chooses a replica for each connection. Ice keeps a connection open as long as it is in use, so all the invocations sent over a connection reach the same replica. You add or remove a replica in the configuration of the load balancer.
Using a Host Name with an Address for Each Replica
An endpoint can name a host whose DNS record holds the address of each replica:
hello:tcp -h hello.example.com -p 4061When Ice establishes a connection, it connects to one of the addresses of this host name, as described in Connection Establishment. Which replica a new connection reaches depends on the order in which the resolver returns the addresses, so load balancing across the replicas relies on the DNS server rotating these addresses.
With this configuration, all the replicas must use the same port. You add or remove a replica by updating the DNS record; the connections already established to a replica stay open after you remove its address. A replica that is down stays in the record until you remove it, and a connection attempt that reaches its address fails or times out before Ice tries the next address.