1
votes

I am new to azure service fabric and i am trying to understand how stateful services works and how state is managed.

Let's say a have stateful service with these replicas:

  • one primary
  • two active secondary
  • one idle secondary

Stateful service has open communication endpoint which is called from number of stateless services. When primary replica changes state, changes are replicated to the two active secondary. Am i correct?

Can secondary replicas be called from one of the stateless services or only primary replicas can accept requests?

If secondary replicas can be called is there away to be notified when primary replica changes state? I tired StateManagerChanged and DictionaryChanged but are only called on the primary replica?

Also I would like ho request divided between primary replica and active secondary?All go to primary except one that are specifically marked for secondary replica ?

1

1 Answers

2
votes

There is a bunch of documentation about this on the Microsoft sites.

However the basics appear to be:

  • State is replicated across the number of replicas.
  • Transactions are used to replicate the state
  • The primary is responsible for writing and sends updates to the replicas
  • There is batching performed by service fabric for efficiency
  • When a primary goes down, either through failure, load balancing or upgrades, one of the active secondary takes over as soon as the primary has finished. My experience of this indicates that once a primary is about to go down, you can't save any state.
  • There are ways to read from active secondaries, but I haven't yet done that myself

The bottom line as far as I can tell is to design services to assume they will fail and everything will work well. When a primary goes down, one of the secondaries will take over almost immediately.