Saturday, May 21, 2022

 

Azure Service Fabric Cluster Instance and Replicas:

This is a continuation of the Azure Service Fabric articles with most recent one as included here. The Azure Service Fabric instance allows specifying the TargetReplicaSize and the MinReplicaSetSize for a stateful service. The first determines the number of replicas that the system creates and maintains for each replica set of a service. The MinReplicaSetSize is the minimum allowed number of replicas for each replica set of a service.

These two parameters allow a configuration that permits two concurrent failures to occur without the partition going in a quorum loss. That situation can happen when there’s one planned failover upgrade bringing node or replica down and one unplanned failover such as when node crashes.

If the TargetReplicaSetSize = 5, MinReplicaSetSize = 3, then without failures, there will be five replicas in the view of the replica set and if failures occur, then the ServiceFabric will allow a decrease until it reaches MinReplicaSetSize.

ServiceFabric uses the majority quorum of the number of replicas maintained in this view and that is the minimum level of reliability for the operation of the cluster. If the replicas follow below this level, then further writes will be disallowed. Examples of suboptimal configurations involve a quorum loss of TargetReplicaSetSize = 3 and MinimumReplicaSetSize = 2 or when both are equal.

Stateless services do not need to specify replicas. They can have their instances scaled to the same count as in a replica set size. An instance of a stateless service is a copy of the service logic that runs on one of the nodes of the cluster. An instance within a partition is uniquely identified by its instanceId.

The lifecycle of an instance is modeled in a cycle of transitions between Inbuild stage, Ready stage, Closing stage and Dropped stage with an occasional transition from Ready to Dropped.

The Inbuild stage of a ClusterResourceManager determines the placement for the instance and enters its lifecycle. The instance is started on the node. When it exits it transitions to the ready state.  If the application host or node for this instance crashes, it transitions to the dropped state.

In the closing state, the Service Fabric is in the process of shutting down the instance on a node. When it completes the shutdown, it transitions to the dropped state. In the dropped state, the metadata maintained by the Service Fabric is marked to be deleted.

A replica of a stateful service is a copy of the service logic running on one of the cluster nodes. The replica lifecycle has a few additional stages: down, opening and stand-by. The down state is when the replica code is not running. The opening state is when ServiceFabric needs to bring the replica back up again. A standby stage is entered when a replica was down and is open now but has not entered the replica set. If the keep duration expires, the standby is discarded.

The role of a replica determines its function in the replica set which includes Primary, ActiveSecondary, IdleSecondary, None and Unknown.

 

 

No comments:

Post a Comment