Deploy Microservices In Production

 

 

 

 

Written by Mehdi CHEBBAH & Yacine ZIDELMAL.


How to deploy a microservices application


Introduction

In this article we will learn the difference between deploying a monolithic application and deploying a microservices application, we will discuss the different available options and the advantages and disadvantages of each of them. So lets get straight into it.

Deploying a monolithic application means running multiple, identical copies of a single, usually large application. You typically provision N servers (physical or virtual) and run M instances of the application on each one. The deployment of a monolithic application is not always entirely straightforward, but it is much simpler than deploying a microservices application.

A microservices application consists of tens -or even hundreds- of services. Services are written in a variety of languages and frameworks. Each one is a mini‑application with its own specific deployment, resources, scaling, and monitoring requirements. For example, you need to run a certain number of instances of each service based on the demand for that service. Also, each service instance must be provided with the appropriate CPU, memory, and I/O resources. What is even more challenging is that despite this complexity, deploying services must be fast, reliable and cost‑effective.

Deployment techniques

There are multiple ways of deploying a microservices based system, here they are:

Multiple service instances per host

The first way is to run multiple instances of different services on a host (Physical or Virtual machine). The deployed system looks like this:

The benefits of this pattern include:

The drawbacks of this approach include:

Single service instance per host

The second option is to deploy each single service instance on its own host. An example of this deployment pattern is shown here:

The benefits of this approach include:

The drawbacks of this approach include:

Service instance per VM

Package the service as a virtual machine image and deploy each service instance as a separate VM. This means the system will look like this:

The benefits of this approach include:

The drawbacks of this approach include:

Service instance per Container

Package the service as a container image and deploy each service instance as a container. Docker could be used to create container images and these containers could be manipulated using a framework such us Docker Compose, Kubernetes, Marathon/Mesos, ...etc. This solution is presented in the following figure:

The benefits of this approach include:

The drawbacks of this approach include:

Conclusion

We can recap the pros and cons of the mentioned 4 strategies in the following table:

 Multiple instances per hostSingle instance per hostSingle instance per VMSingle instance per container
IsolationNo isolationIsolatedIsolatedIsolated
Risk of conflictsYesNoNoNo
Resources managementNoYesYesYes
third-party solutionsNo solutionsSome solutionsMultiple solutionsA lot of solutions
Resources efficiencyEfficientNot efficientEfficientVery efficient
ScalingHardEasyVery easyVery easy
Build time//SlowFast

Further Reading

  1. Deploying Microservices: Choosing a Strategy (2016) NGINX. Available at: https://www.nginx.com/blog/deploying-microservices/ (Accessed: 24 December 2021).
  2. Deploying microservices. Available at: https://microservices.io/articles/deployment.html (Accessed: 24 December 2021).