Demystifying Azure Service Fabric

Azure Service Fabric is an application platform that simplifies building and deploying microservice based applications and containers. It provides an easy way to package, deploy, and manage scalable and reliable applications whether they run in Azure, on-premises, or in other clouds.

The IT professionals and developers can avoid complex infrastructure problems as these are managed by the Azure Service Fabric.
 
As we know, the Microservice based architecture splits an application into a set of fine-grained loosely coupled services. These interconnected/inter-related services can be updated and scaled independently. However, to make the Microservice based approach work, the developer has to write complex and mission-critical code in areas like inter-service communication and handling failure.
 
This is where Microsoft Azure Service Fabric comes into the picture. Azure Service Fabric provides built-in programming model to simplify developing Microservices. In addition to traditional stateless Microservice, it supports stateful Microservice, co-locating compute and data to reduce latency and enhance performance by providing reliability through replications and persistence.
 
Data Partition Service, Dynamic Resource Balancing, Scaling on-demand and health check features of Service Fabric provides zero application downtime and if health-check fails, Service Fabric automatically rolls back the application to a previous version. Many Azure services such as Azure Event Hub, Azure SQL Database, Document DB as well as other Microsoft products such as Intune, Bing, Cortana, Skype for Business run on Azure Service Fabric.
 
Azure Service Fabric provides management capabilities including state management, application life-cycle management, diagnostics and monitoring, and service discovery. It simplifies the building and deploying of Microservice based applications in Azure, in other clouds, on-premises. And, AFS supports Windows as well as Linux.
 
Azure Service Fabric Programming Model
 
Using Service Fabric, developers have multiple ways to write and manage services. A service can be any compiled executable program written in any language or code running in a container hosted on a Service Fabric Cluster.
 
Azure Service Fabric offers the below-mentioned programming model to develop your services.
  • Guest Executables
  • Containers
  • Reliable Services
  • ASP.NET Core
  • Reliable Actors
Guest Executable
 
Guest Executable is an existing code written in any language that can be run as a service in your application. These guest executables are benefitted from features that the platform offers, such as service discoverability, custom health, and load reporting by calling the REST APIs exposed by Service Fabric rather than calling the Service Fabric SDK APIs directly.
 
Containers
 
Service Fabric deploys and activates the services as a process. Service Fabric can also deploy services in containers. Service Fabric supports the deployment of Linux containers and Windows Containers on Windows Server 2016. We can pull container images from any container repository, such as Docker Hub or ACR.
 
Reliable Services
 
Reliable Service is a light-weight framework for writing services that integrate with the Service Fabric platform and benefit from the full set of platform features.
 
Reliable Services expose APIs that allow the Service Fabric runtime to manage the lifecycle of your services and that allows your services to interact with the runtime.
 
Reliable Services can be stateless such as web servers, in which each instance of the service is created equally and state is persisted in an external solution such as Azure DB or Azure Table Storage.
 
An exclusive feature of Service Fabric allows you to create a stateful where the state is persisted directly in the service itself using Reliable collections. Here, the state is made highly available through replication and distributed through partitioning - all managed by Service Fabric.
 
ASP.NET Core
 
You can write both stateless and stateful ASP.NET Core applications in conjunction with Service Fabric and ASP.NET Core.
 
Reliable Actors
 
The Reliable Actors API is a high-level framework provided by Service Fabric. Reliable Actors is based on Actor pattern. Actors are isolated, independent units of logic and state within a single-threaded execution model. It is useful in achieving concurrency by having many actors executing simultaneously and independently from each other.
 
Use Actors for low latency scenarios that can be modeled with practices like Domain Driven Development.
 
Service Fabric itself is made up of different Microservices such as,
  • Cluster Manager Service
  • Failover Manager Service
  • Fault Analysis Service
  • Image Store Service
  • Naming Service
  • Upgrade Service
Azure Service Fabric Cluster
 
Your Microservices would be deployed and managed into a network-connected set of virtual or physical machines called Service Fabric Cluster.
 
Each cluster is made of a node or a cluster node.
 
A node is a machine or a VM.
 
If you add new nodes to the cluster, Service Fabric rebalances the service partition replicas and instances across the increased number of nodes.
 
Each service Fabric cluster can have multiple types of nodes. Each node 'type' pertains to a different hardware configuration and scale set. In Microsoft Azure cloud, this will be a specific virtual machine type such as 'D2'. This allows you to provision different hardware sets for a different application or service types. For example, you can place your Web Front End nodes on smaller node types like D2_V2 and computed optimized web service on a bigger one such as D4_V2.
 
Service Fabric Clusters are made up of some high-level Azure resources as mentioned below.
  • Virtual Machine Scale Set
  • Load Balancer
  • Virtual Network