Reliable Services

The Reliable Services framework is used for writing Microservices using traditional .NET constructs. The framework helps Service Fabric provide reliability, availability, consistency and scalability to your service. Using the Reliable Services model, you can create both stateless and stateful Microservices.

  • Stateless Reliable Service: A stateless Microservice in Service Fabric does not contain any state data that needs to be stored reliably or made highly available. There is no affinity of requests to the services, therefore stateless services store any state data in external store such as Azure SQL database or Redis cache.
  • Stateful Reliable Service: A stateful Microservice in Service Fabric can reliably maintain state that is co-located with the executing code of the Microservice. The Service Fabric platform ensures that the state data is replicated, consistent and highly available. The Service Fabric application programming framework provides a few collection types that can be used to store state data with reliability guarantees. These collection classes are part of Microsoft.ServiceFabric.Data.Collections namespace and are called Reliable Collections. High availability and strong consistency of state data in these collections is guaranteed by writing transactional state data to a majority quorum of replicas, including the primary replica.

At the time of writing, the namespace Microsoft.ServiceFabric.Data.Collections contains three collections:

  • ReliableDictionary: ReliableDictionary is similar to the ConcurrentDictionary collection in the System.Collections.Concurrent namespace. However, unlike the ConcurrentDictionary collection, it represents a replicated, transactional, and asynchronous collection of key-value pairs. Similar to ConcurrentDictionary, both the key and the value can be of any type.
  • ReliableQueue: ReliableQueue is similar to the ConcurrentQueue collection in the System.Collections.Concurrent namespace. Just like the ReliableDictionary collection, it represents a replicated, transactional, and asynchronous collection of values. However, it is a strict first-in, first-out (FIFO) queue. The value stored in a ReliableQueue can be of any type.
  • ReliableConcurrentQueue: ReliableConcurrentQueue is a new Reliable Collection of persisted, replicated values that allows concurrent reads and writes with best-effort. FIFO ordering. ReliableConcurrentQueue supports higher throughput and therefore does not guarantee FIFO behavior like the ReliableQueue does. Also, while ReliableQueue restricts concurrent consumers and producers to a maximum of one each, ReliableConcurrentQueue imposes no such restriction, allowing multiple concurrent consumers and producers.

We will learn more about Reliable Services in the next chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset