Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Microservices with Azure

You're reading from  Microservices with Azure

Product type Book
Published in Jun 2017
Publisher Packt
ISBN-13 9781787121140
Pages 360 pages
Edition 1st Edition
Languages
Authors (2):
Rahul Rai Rahul Rai
Profile icon Rahul Rai
Namit Tanasseri Namit Tanasseri
Profile icon Namit Tanasseri
View More author details

Table of Contents (23) Chapters

Title Page
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface
Part 1 – Laying The Foundation
Part 2 – Microsoft Azure Service Fabric
Part 3 – Microservice Architecture Patterns
Part 4 – Supplementary Learning
1. Microservices – Getting to Know the Buzzword 2. Microsoft Azure Platform and Services Primer 3. Understanding Azure Service Fabric 4. Hands-on with Service Fabric – Guest Executables 5. Hands on with Service Fabric – Reliable Services 6. Reliable Actors 7. Microservices Architecture Patterns Motivation 8. Microservices Architectural Patterns 9. Securing and Managing Your Microservices 10. Diagnostics and Monitoring 11. Continuous Integration and Continuous Deployment 12. Serverless Microservices

Chapter 3. Understanding Azure Service Fabric

Microservices architecture portrays efficient mechanisms of solving modern enterprise problems. However, this simplification comes at a cost. Manually managing hyperscale deployments of Microservices is nearly impossible. Automating Microservices lifecycle management becomes an inevitable requirement to achieve enterprise-grade environment stability. This is where the role of Azure Service Fabric becomes significant. To start with, let's try to understand what Service Fabric is.

Mark Fussell, a senior program manager in the Microsoft Azure Service Fabric team, defines Service Fabric as the following:

Service Fabric is a distributed systems platform that makes it easy to package, deploy, and manage scalable and reliable Microservices.

Let's dig deeper into this definition. The definition categorizes Service Fabric as a platform. A platform, in theory, is a software component capable of hosting other software applications which are built to align...

The Service Fabric advantage


Now that we understand what Service Fabric is, let's look at the advantages of using it as a platform to host Microservices.

As discussed in the earlier section in this chapter, Service Fabric is a distributed systems platform used to build hyperscalable, reliable, and easily managed applications for the cloud. The following figure mentioned in MSDN, provides a good overview of capabilities of Service Fabric as a hosting platform for Microservices:

Service Fabric features

Apart from the capabilities of Service Fabric to manage the application lifecycle for Microservices, the preceding diagram provides an important aspect of its ability to be deployed across heterogeneous environments. We will talk about this in detail in later sections of this chapter. Let's now dive deeper in to few of the key features of Service Fabric which make it an ideal platform to build a Microservice-based applications.

Highly scalable

Every Microservice hosted on Service Fabric can be scaled...

Service Fabric as an orchestrator


From a service management point of view, Service Fabric can be thought of as an orchestrator. An orchestrator in general terms is an automated piece of software used to manage service deployments. This piece of software is supposed to abstract the complexities around provisioning, deploying, fault handling, scaling, and optimizing the applications it is managing, from the end user. For instance, an orchestration should be able to consume a configuration which specifies the number of instances of service to run and perform the task of deploying the services-based on multiple complex factors such as resource availability on nodes in a cluster, placement constraints, and so on

Orchestrators are also responsible for fault handling and recovery of services. If a node in a cluster fails, the orchestrator needs to gracefully handle this while ensuring service availability. Updating a service deployment or applying a patch to the underlying framework is also managed...

Architecture of Service Fabric


Service Fabric is a collection of services grouped into different subsystems. These subsystems have specific responsibilities. The following diagram illustrates the major subsystems which form the Service Fabric architecture:

Subsystems of Service Fabric

The first layer from the bottom, the Transport Subsystem is responsible for providing secure communication channels between nodes in a Service Fabric cluster. The Federation Subsystem above it helps logically group physical or virtual nodes into a cluster so that it can be managed as a unit. This helps Service Fabric with tasks such as failure detection, leader election, and routing. Reliability of the workload hosted on Service Fabric is managed by the Reliability Subsystem. It owns the responsibility of replication, resource management, and failover. The Hosting & Activation Subsystem manages the lifecycle of the workload on every node and the Management Subsystem is responsible for managing the lifecycle of applications. The Testability Subsystem helps developers test their workload before and after deployment. Service location of services hosted on Service Fabric is managed by Communication Subsystem. The top three boxes capture the application programming models and the application model available for the developers to consume. More about application models is discussed in later parts of this book.

Transport Subsystem

The Transport Subsystem provides a communication channel for intra and inter cluster communication. The channels used for communication are secured by X509 certificate or Windows security. The subsystem supports both one-way and request-response communication patterns. These channels are in turn used by the Federation Subsystem for broadcast and multicast messaging. This subsystem is internal to Service Fabric and cannot be directly used by the developers for application programming.

Federation Subsystem

Federation Subsystem is responsible for logically grouping virtual or physical machines together to form a Service Fabric cluster. This subsystem uses the communication infrastructure provided by the Transport Subsystem to achieve this grouping. Grouping of nodes helps Service Fabric better manage the resources. The key responsibilities of this subsystem includes failure detection, leader election, and routing. The subsystem forms a ring topology over the nodes allocated for the cluster. A token-leasing mechanism along with a heartbeat check is implemented within the system to detect failures, perform leader election, and to achieve consistent routing.

Reliability Subsystem

Reliability of the service hosted on the platform is ensured by the Reliability Subsystem. It achieves these tasks by managing failover, replicating, and balancing resources across nodes in a cluster.

The replicator logic within this subsystem is responsible for replicating the state across multiple instances of a service. Maintaining consistency between the primary and the secondary replicas in a service deployment is its main task. It interacts with the failover unit and the reconfiguration agent to understand what needs to be replicated.

Any changes in the number of nodes in the cluster trigger the failover manager service. This in turn triggers automatic redistribution of services across the active nodes.

The resource manager plays the part of placing service replicas across different failure domains. It is also responsible for balancing the resources across the available nodes in the cluster while optimizing the load distribution and resource consumption.

Management Subsystem

The application lifecycle management of workloads deployed on a Service Fabric cluster is owned by the Management Subsystem. Application developers can access the Management Subsystem functionalities through administrative APIs or PowerShell cmdlets to provision, deploy, upgrade, or de-provision applications. All these operations can be performed without any downtime. The Management Subsystem has three key components – cluster manager, health manager, and image store.

The cluster manager interacts with the failover manager and the resource manager in the Reliability Subsystem for deploying the applications of available nodes considering the placement constraints. It is responsible for the lifecycle of the application, starting from provisioning to de-provisioning. It also integrates with the health manager to perform health checks during service upgrades.

Health manager, as the name suggests, is responsible for monitoring the health of applications, services, nodes, partitions, and replicas. It is also responsible for aggregating the health status and storing it in a centralized health store. APIs are exposed out of this system to query health events to perform corrective actions. The APIs can either return raw events or aggregated health data for a specific cluster resource.

The image store is responsible for persisting and distributing application binaries deployed on a Service Fabric cluster.

Hosting subsystem

The Hosting Subsystem takes care of managing application deployments within the scope of a node. The cluster manager signals the Hosting Subsystem, informing it about the application deployments to be managed on a particular node. The Hosting Subsystem then manages the lifecycle of the application on that node. It interacts with the Reliability Subsystem and Management Subsystem to ensure the health of each deployment.

Communication subsystem

The communication subsystem provides features for service discovery and intra-cluster messaging features using a naming service. The naming service is used to locate a service within a cluster. It also lets users securely communicate with any node on a cluster, retrieve service metadata, and manage service properties. The naming service also exposes APIs, which enables users to resolve network location or each service despite of them being dynamically placed.

Testability Subsystem

The Testability Subsystem provides a list of tools for developers, deployment engineers, and testers to introduce controlled faults and run test scenarios to validate state transitions and behaviors of services deployed on Service Fabric. The fault analysis service is automatically started when a cluster is provisioned. When a fault action or test scenario is initiated, a command is sent to the fault analysis service to run the fault action or test scenario.

Deconstructing Service Fabric


A Service Fabric application can be logically decomposed into multiple components. As a pro developer, you write your application using one of the programming models and supply the necessary configurations and data to make your code work, Service Fabric takes care of the rest of the stack and ensures that your code executes in a reliable and highly available environment. Let us take a look at the various components of a Service Fabric application and go through the individual components, starting from the infrastructure model:

Components of Service Fabric application

Infrastructure model

In a distributed computing platform such as Service Fabric, the computing load is distributed over all the available compute units, which are actually a number of virtual machines that work together. Because Service Fabric clusters can be deployed on any platform and on physical or virtual machines, your Service Fabric applications can run on a variety of platforms without any...

Creating a cluster on Azure


We have discussed quite a few concepts by now. Let's create a Service Fabric cluster in Azure and map the concepts that we learnt with the components. These steps to create a Service Fabric cluster on Azure are also documented on the Microsoft Azure documentation site at:https://azure.microsoft.com/en-us/documentation/articles/service-fabric-cluster-creation-via-portal/.

Note

Although you can work with almost all the samples in this book on your system, you would need a Microsoft Azure subscription to deploy your production workload. We recommend that you get a Microsoft Azure subscription now. You can get started with a free one month trial at: https://azure.microsoft.com/en-us/free/.

Perform the following steps to create a Service Fabric Cluster:

  1. Sign in to the Azure Management Portal at: https://portal.azure.com.
  2. Click New to add a new resource template. Search for the Service Fabric Cluster template in Marketplace under Everything:

Service Fabric cluster template...

Service Fabric Explorer


Service Fabric Explorer is a web-based tool that is built using HTML and AngularJS and is included in every cluster, including the local cluster, at port 19080. You can access the explorer at http(s)://clusteraddress:19080/Explorer.

You can use the Service Fabric Explorer tool for inspecting and managing applications and nodes in an Azure Service Fabric cluster. The left-side section of Service Fabric Explorer provides a tree view of your cluster and to the right is a pane showing details of the selected item and an ACTIONS button with possible actions you can perform on the item:

Service Fabric Explorer

Let's take a look at the layout of Service Fabric Explorer.

Summary view

The cluster dashboard provides an overview of your cluster, including a summary of application and node health:

Service Fabric Explorer Cluster Summary

Cluster Map

You can also view the placement of nodes in your cluster by clicking on the Cluster Map button. To ensure high availability of your services...

Preparing your system


To get started with developing applications on Service Fabric, you will need to the following:

  1. Install the runtime, SDK, and tools.
  2. A Service Fabric cluster to deploy your applications.
  3. Configure PowerShell to enable SDK script execution.

We are going to use C#, Visual Studio 2015, and Windows 10 to develop all samples in this book.

Note

You can find the steps to to prepare your development environment on various operating systems at this link: https://azure.microsoft.com/en-us/documentation/articles/service-fabric-get-started/.

To install the SDK, tools, and Service Fabric runtime, use the Web Platform Installer (Visual Studio 2015) or enable Service Fabric workload (Visual Studio 2017). You can read more about these options at:

https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-get-started.

Service Fabric uses Windows PowerShell scripts for creating a local development cluster and for deploying applications from Visual Studio. By default, Windows blocks these...

Summary


In this chapter, we covered the features of Service Fabric which make it an ideal platform to host Microservices. We discussed how Service Fabric acts as an orchestrator for managing Microservices.

In the second section of the chapter, we covered the architecture of Service Fabric in detail and studied the cluster services. Next, we discussed the infrastructure model, system services, and programming models available to build and host applications on Service Fabric.

Finally, we walked through the steps for creating a Service Fabric cluster on Azure and preparing our system to get started with developing applications on Service Fabric.

In the next chapter, we will dive deeper into building applications on Service Fabric.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Microservices with Azure
Published in: Jun 2017 Publisher: Packt ISBN-13: 9781787121140
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}