Financial Year 2023 End Sale: Get upto 40% OFF on Job-oriented Training! Offer Ending in
D
H
M
S
Get Now
Getting Started with Azure Service Fabric

Getting Started with Azure Service Fabric

29 Mar 2024
Beginner
14.8K Views
7 min read

Traditional monolithic style application architecture coupled all their functionality tightly into one service. This caused high difficulty to deploy new features as it will take long downtimes which resulted in fewer opportunities to make updates to the application. Scaling such applications are expensive because we have to scale the whole application even though only a particular service gets much traffic.

The introduction of the cloud has brought a drastic change in the way we design, architect and deploy our applications. Helped in faster deployments, improving availability, ability to scale on demand and reduced the time to market. So here comes in the Microservices-based application, which is an architecture in which the goal is to create smaller isolated services that can deploy and scale independently of each other improving the agility.

Azure Service Fabric

Architecting a microservice based application needs developers to write additional code for communication between services and handling failures. This is where the Microsoft Azure Service Fabric comes in which simplifies building and deploying microservice based applications to provide organizations with scalable agile and reliable applications, whether they run in Azure, on-premises or in other clouds. And developers get to focus on code that delivers business value which means customers get new features faster.

Azure Service Fabric Source: https://docs.microsoft.com

Azure service fabric protects applications against failures by monitoring the health status of the cluster, reporting or automatically acting to reduce issues. It is equipped with many built-in programming models to simplify development which not only lets you run any application code in traditional stateless microservices but also supports stateful micro-services co-locating compute and data to reduce latency and enhance performance.

Azure Service Fabric used by Microsoft

Microsoft has been using Azure Service Fabric in production for years for its own internal evolution for some of the products, from on-premises to cloud and from monolithic to microservice-based applications. Azure Service Fabric had powered the services including, Azure Document DB, Azure SQL Database, Skype for business, Intune and Cortana. They have released the same technology they have been using for themselves as a service in Azure.

Azure Service Fabric Programming Models

In Azure Service Fabric, the services can be written in any type language or code running in a container host or cluster by using the Service Fabric APIs to take full advantage of the platform's features and application frameworks.

  • Guest executables : Any existing or arbitrary executable code written in any language can be run as guest executables in service fabric. They are placed on nodes in the cluster but can’t directly call the Service Fabric SDK APIs. But will still benefit features from the platform like health monitoring, density, discoverability, load reporting and full application lifecycle management

  • Containers : You can deploy Linux/Windows containers in Service Fabric without any changes to your application. In the same application, you can have a combination of both services in processes and services in containers. Service Fabric stateless or stateful reliable services or Reliable Actors in containers

  • Reliable Services : Service Fabrics own programming models for gaining some additional features which are light-weight, powerful and help you to express what is important to your application. This is automatically managed by Service Fabric and can be of stateless or stateful. Features like replication and partitioning make reliable services highly-available.

  • ASP.NET Core : Service Fabric integrates with ASP.NET Core supporting both stateless and stateful applications with an added advantage of Reliable Collections advanced orchestration capabilities.

  • Reliable Actors : An application framework, built on top of Reliable Services, which implements the Virtual Actor pattern. It will be based on the actor design pattern and can benefit all the features offered by the Azure Service Fabric platform.

  • Azure Service Fabric Concepts

  • Cluster: A collection of virtual or physical machines connected to each other through a network into which we deploy and manage our microservices, which is capable of scaling to thousands of machines.

  • Node: A single physical or virtual machine in that cluster, assigned with a name. Nodes have placement properties, auto-start Windows service. It’s also possible to host multiple nodes on a single physical or virtual machine by using some executables.

  • Applications and services: A collection of services is called as an application while a service is a complete functional unit that delivers certain functionalities. We define the type of the application and its associated service types to author a Service Fabric application. As the code, configuration, and data are isolated from each other in Service Fabric you can deploy multiple version of the applications in the same cluster.

  • Partitions and replicas: A service is capable of having one single or multiple partitions and a partition can have many replicas. Partitions are used as the scaling mechanism to distribute workloads to different service Having one primary replica and multiple secondary replicas, if primary replica fails, the secondary replica automatically is promoted to primary to keep service availability and they will add required more secondary replicas to bring back to the desired level to keep enough redundancy.

  • Stateless: A Service, where there is no requirement to capture the state for future purposes. For example, think of an application to create a thumbnail from an image. As each time we are provided with a new image we need not capture any state there for any future purposes, so we use stateless service.

  • Stateful: In a stateful service we need to capture our service's state. For example, in case of a shopping cart, where the user adds some products from some pages and then, moves on to a different page where he selects another product, we need to use stateful microservices to retain the states. Modifying names service state of primary replica will replicate to all secondary replicas by service fabric.

  • Guest executables: Executables written in any language, such as Node.js, Java, or C++ that run as-is on the host operating system which doesn't link or refers to any Service Fabric runtime files. These types can’t use some features of Service Fabric such as the naming service for endpoint discovery.

Cloud Services vs Service Fabric

Applications and infrastructure

In Cloud Services we deploy applications as Virtual Machines where the code is coupled to an instance. There is no difference between an application and VM definition here as both are considered as one, while in Service Fabric we just deploy our applications into existing virtual machines where the service is completely decoupled from the underlying infrastructure.

Application architecture

We might be having a lot of external service dependencies in cloud service architecture like tables, storage and cache. The service fabric can also follow the same by just replacing the cloud service deployment with the service fabric stateless services in a simple migration with minimal code change or use stateful features by writing some custom services.

Communication and workflow

The communication between different tier in case of cloud service and service in case of Service Fabric happens commonly in two models: direct and via an external durable storage. In cloud services tiers communicate directly by selecting the instance of the VM role and connecting to the endpoint directly, while in service fabric we just connect to a service.

Advantages of Azure Service Fabric

  • Fast deployment times as creation of virtual machines are time consuming while in service fabric its quick to deploy in clusters.

  • High density hosting as we can deploy large number of applications to smaller number of VMs.

  • Ability to run in any environment or in any operating systems. Not mandatory to be in Azure, can run in on-premises also.

  • Distributed application management.

Summary

Being born from years of experience in delivering mission-critical cloud services within Microsoft itself, Service Fabric enables hundreds of other organizations also enjoy the same benefits as-a-service through Microsoft Azure. The support for many developer tools and programming models improves developer productivity and can be used to build stateless services and stateful microservices. It also supports features like Application Lifecycle Management, State Management, Zero downtime upgrades and health diagnostics and monitoring.

Have you heard about Microservices Architecture is the must-have skills for IT professionals? To enable you to upgrade your existing skills to learn how to implement Microservices in your existing and upcoming projects. Keeping the same in mind, we at Scholarhat deliver an Unlimited Microservices online training program that's aligned with real-time with projects implementation.

Share Article
About Author
Mohammed Ramees P (An Author and Corporate Trainer)

Passionate Youth Training Professional with strong computer science background and a passion for mentoring and sharing expertise with others on various technologies. Started as Microsoft Student Partner while being in campus, he has been part of Microsoft Certified Trainer in 2015 and Microsoft Most Valuable Professional awardees in 2016. A motivational and engaging public speaker, with experience and creativity to develop interactive programs that maximize adoption of complex technologies to students with diverse skills levels.
Accept cookies & close this