Session locations are tracked by partitions. Partitions are evenly distributed across the hosting peers of a Service Space. The management of these partitions is performed by a Partition Manager, which:
- When the first hosting peer, Node 1, of a given Service Space starts:
- all the partitions are allocated to Node 1.
- When a second hosting peer, Node 2, starts:
- 6 partitions owned by Node 1 are transferred to Node 2 by Node 1.
- When a third hosting peer, Node 3, starts:
- 2 partitions owned by Node 1 are transferred to Node 3 by Node 1; and
- 2 partitions owned by Node 2 are transferred to Node 3 by Node 2.
When a peer hosting some partitions fail, lost partitions are repopulated by the peers becoming the new owner of these partitions:
- Node 3, hosting some partitions, dies.
- The node hosting the partition rebalancing singleton service queries all the nodes in the cluster for the partitions they are owning.
- The partition rebalancing service identifies that:
- some indexes have disappeared and need to be recreated; and
- the disappeared partitions are to be managed by Node 1.
- The partition rebalancing service provides to all the nodes a new partition distribution plan.
- Node 1, which is instructed to acquire some lost partitions, queries the cluster for all the sessions belonging to the lost partitions.
- Node 1 repopulates the lost partitions based on the responses of the above query.
State Manager is responsible for updating the session locations tracked by partitions when sessions are created, evacuated or destroyed: