Written by Mehdi CHEBBAH & Yacine ZIDELMAL.
IntroductionDeployment techniquesMultiple service instances per hostSingle service instance per hostService instance per VMService instance per ContainerConclusionFurther Reading
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.
There are multiple ways of deploying a microservices based system, here they are:
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:
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:
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:
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:
We can recap the pros and cons of the mentioned 4 strategies in the following table:
Multiple instances per host | Single instance per host | Single instance per VM | Single instance per container | |
---|---|---|---|---|
Isolation | No isolation | Isolated | Isolated | Isolated |
Risk of conflicts | Yes | No | No | No |
Resources management | No | Yes | Yes | Yes |
third-party solutions | No solutions | Some solutions | Multiple solutions | A lot of solutions |
Resources efficiency | Efficient | Not efficient | Efficient | Very efficient |
Scaling | Hard | Easy | Very easy | Very easy |
Build time | / | / | Slow | Fast |