📜 ⬆️ ⬇️

Azure microservice application

This publication focuses on two microservice applications that are created and deployed in Microsoft Azure Service Fabric and in Azure Container Service. Although the focus is on microservice-based applications running in Azure Service Fabric and Azure Container Service, it should be noted that Azure is an open platform that allows you to run microservice-based applications using various technologies, such as CloudFoundry, RedHat Openshift or Kubernetes .



Azure Service Fabric


Let's start with the Azure Service Fabric microservice platform. It provides an opportunity to develop and pack reliable scalable microservices in and out of containers, as well as to manage them. The Service Fabric platform has over 300 users, including companies such as BMW and Schneider Electric.

Service Fabric clusters can be prepared for use in virtually any environment, such as Azure , a local environment, a private cloud, or a solution from other cloud service providers. The publicly available version of Service Fabric runs under Windows, but there is also a version for Linux available for private preview. Follow the link to learn more about deploying a Service Fabric based on Windows Server or Linux .
')
In addition to the main features of the platform , which include rapid deployment, deployment of services, high reliability, high density, health reports, coordinated updates and service endpoint detection for any type of application (Node.js, Java, etc.) in Service Fabric programming models are supported for creating microservices with and without state tracking. Programming models are currently available for .NET on Windows and for Java on Linux.

By contrast, stateful Service Fabric microservices maintain state locally in computing instances. Due to this, delays in reading and writing are reduced, and the overall architecture is simplified as the components to be moved become smaller. One of the primary goals of Service Fabric is to maintain data reliability and consistency. Replication is used for this.

Example of using microservices


The TalkTalk streaming and encoding solution was originally created using the Lift and Shift methodology as part of the Azure infrastructure as a service offering, as it was the easiest way to transfer the entire application to the cloud. However, in the context of continuous and rapid business growth and the emergence of new requirements, TalkTalk developers began to implement a microservice based approach in some parts of their application, using Azure Service Fabric as a platform.

Due to this, they were able to simplify the deployment of services, to obtain more flexible scalability of each service, as well as eliminate downtime when updating individual services. A microservice based application also integrates well with Azure Media Services and Azure Batch.

The figure shows the general architecture of a microservice application and the course of processing a coding request in such an application.

Below is a description of the role of each microservice in processing a request:

Step 1 . The TalkTalk client invokes the EncodeRequest method available to the Activity Web API via the Azure management API.

Step 2. The stateless Activity Web API is an Open Web Interface for .NET (OWIN) listener. It contains the API controller, which provides the ability to create new encoding requests. Services outside of the Service Fabric use this API for external communication. He receives calls from the API Management Service.

Step 3. The stateful Activity Microservice uses the Secure Queue API in the Service Fabric for inbound operation. Then this microservice creates an action subject representing the coding work that needs to be performed.

Step 4. Microservice ActivityActor presents a list of work items to track the progress of each step and to create the actors of each step. The created subjects monitor the state, so even in case of failures, the data is not lost due to their replication.

Step 5. Microservice ActivityStepActor coordinates the work stages. Work is being done in other Service Fabric applications. For example, an application for managing encryption jobs uses Azure Batch to perform the custom encryption step required for TalkTalk set-top boxes. The application itself for managing encryption jobs contains many microservices and encapsulates the necessary interactions with Azure Batch. The action step subject communicates with the appropriate services using the service proxy provided by the Service Fabric platform.

A stateless ActivityStep microservice provides access to the Service Communication Listener, so other Service Fabric services, such as the Azure Media Services (AMS) job management application (step 6) and the encryption job management application (step 7), can interact with the activity steps. . This way of working is similar to callbacks: for example, when the Batch service is shutting down, you need to contact ActivityStepActor to complete or update the work phase.

During this process, a reminder about each subject is used to periodically save the state of the subject in DocumentDB. This is done for two purposes: first, to provide the ability to perform arbitrary requests, and second, to organize the protection and backup of data outside the Service Fabric platform.

A detailed description of the TalkTalk application based on microservices is available here .

Azure Container Service


Azure Container Service (ACS) is another Azure service that allows you to deploy and run microservice-based applications. ACS users include Avanade, ESRi, and CloudBees.

ACS core functionality allows you to create a cluster for managing container loads, using DC / OS or SWARM as an orchestrator. From the point of view of microservices, you are responsible for choosing the means of detecting and registering services, exchanging information, monitoring, and the like. This is also the main difference from the Service Fabric, whose capabilities go beyond the cluster and the orchestrator and include integrated services, including service registration and discovery, as well as programming models.

Benefits of ACS


Let's start with the obvious: using open source software technology (OSS). Considering that ACS uses Docker Swarm and Mesosphere DC / OS, then you have all the resources of the OSS community available for these two technologies. Since these technologies have been available on the market for a long time, you can easily find step-by-step tutorials, training materials, code snippets, and even turnkey solutions for virtually any scenario.

Another advantage is the ease of setting up and managing the cluster using Azure. Those of you who have had to set up a DC / OS or Docker Swarm cluster on bare metal or virtual machines are well aware that this requires much more than just connecting several machines to each other. You also need to configure various additional components and services, provide access to the endpoints, associate agents with the load balancing subsystem, etc. To automate the configuration of such a cluster, you will have to write a fairly lengthy script. ACS simplifies cluster setup by applying templates and abstracting all configuration steps.

However, setting up a cluster of machines with an orchestrator is only half the battle. After setting up and running the cluster, you may need to install patches on the machines in the cluster or upgrade them to a later version of SWARM and DC / OS. Such tasks usually require careful planning. In the future, ACS will support a fully managed infrastructure so that developers can focus only on workloads in a cluster, without wasting time on tasks related to infrastructure management.

You can set up a cluster to work either in the Azure portal or automatically using the Azure Resource Manager template as part of the infrastructure as a service approach. You will need to provide only the following values:


The following snippet shows the Azure Resource Manager template for ACS JSON code.

 “resources”: [ { “apiVersion”: “2016–03–30”, “type”: “Microsoft.ContainerService/containerServices”, “location”: “[resourceGroup().location]”, “name”:”[concat('containerservice-',resourceGroup().name)]”, “properties”: { “orchestratorProfile”: { “orchestratorType”: “[variables('orchestratorType')]” }, “masterProfile”: { “count”: “[variables('masterCount')]”, “dnsPrefix”: “[variables('mastersEndpointDNSNamePrefix')]” }, “agentPoolProfiles”: [ { “name”: “agentpools”, “count”: “[variables('agentCount')]”, “vmSize”: “[variables('agentVMSize')]”, “dnsPrefix”: “[variables('agentsEndpointDNSNamePrefix')]” } ], “linuxProfile”: { “adminUsername”: “[variables('adminUsername')]”, “ssh”: { “publicKeys”: [ { “keyData”: “[variables('sshRSAPublicKey')]” } ] } } } } 

As a result, you get a fully configured DC / OS cluster or Docker Swarm, in which you can deploy applications. The figure shows the output of a fully configured DC / OS-based ACS cluster.

In addition to deployment, ACS integrates with scalable virtual machine sets (VMSS) that will support simple automatic scaling and patch installation for the entire orchestra and the entire infrastructure. As stated above, in ACS, you can deploy and run absolutely any microservice based application. Due to this, when deploying with ACS, very high flexibility is achieved. To run microservice-based applications, you can use any DC / OS or Docker Swarm solutions that you would use in other environments.

Consider an example of a microservice based application where DC / OS is used as an orchestrator in Azure Container Service. Flak.io is an example of an e-commerce application created specifically to demonstrate the capabilities of microservices. This app:


From the user's point of view, this application allows you to browse products in the catalog and buy them.

The application consists of four basic services and interface services:



The figure shows the overall architecture of Flak.io.

The source code for Flak.io is available on GitHub .

Note. Flak.io project is not finished yet. Work continues on the storage of records of events, the creation of recommendations and notification services, but in general this application will provide a fairly complete picture of the design and deployment of the container application based on microservices in ACS.

Results


In this publication, we looked at two examples of microservice architectures: for the Service Fabric and for the Azure Container Service. In general, Service Fabric can be seen as a turnkey solution for building microservice-based applications, in which the Azure Container service can quickly set up a cluster and manage the infrastructure using DC / OS or SWARM so that developers can fully concentrate on writing code. After preparing the ACS cluster, you can use any convenient technologies for applications based on microservices, as well as the possibilities of the ever-growing Docker and Mesoshpere communities.

Useful activities


If you have few articles and would like to communicate remotely or personally with me or colleagues on the creation of microservice and other solutions in Azure, come to us for the following events.

  1. Record webinar on April 11th . New approaches in the cloud architecture: containers and microservices (registration required)
  2. April 19, Moscow, mitap . Microservices in Azure (registration is required through meetup.com)
  3. April 21-23, Moscow, DevCon School . Modern architecture (registration required)

If you’ve read this far and want at DevCon School: Modern architecture , but you don’t have a promo code, write me a message explaining why you want to get there. As usual, I have a few promotional codes for Habra readers .

useful links


  1. Getting started with Service Fabric
  2. Service Fabric for free using Party Clusters clusters
  3. Azure Container Service
  4. Deploying and Running Microservice Based Applications in ACS

Source: https://habr.com/ru/post/326054/


All Articles