Microservices deployment
In Chapter 2, Anatomy of Microservice Decomposition Services, we created a distributed application based on the microservice architecture and architected the application as a set of services. We can now deploy each service as a set of service instances to improve throughput and availability. The microservice architecture makes the service deployable and scalable, meaning all service instances are isolated from each other.
The microservice architecture allows us to build and deploy a service quickly. It also allows us to limit the number of resources used, including CPU, memory, and I/O resources. A microservice application has tens of hundreds of services. You can independently increase or decrease resources of a deployment machine based on the usage of a service. Microservices also allow you to write a service in any language and framework, so you can provide the infrastructure for a service accordingly. You can monitor each service independently and deploy a service according to its behavior.
For example, imagine that you need to run a service with a certain number of instances based on the demand for the service in a business application. With a microservice application, you can easily achieve this by adding multiple VMs or containers for that particular service. You can also provide the appropriate CPU, memory, and I/O resources for each instance. The challenging aspect of a microservice application is that the service deployment must be fast, reliable, and cost-effective.
We have a few strategies that we can use to deploy the microservices of a distributed application; they are as follows:
- Multiple instances of microservices per host
- A single instance of a microservice per host:
- A single instance of a microservice per VM
- A single instance of a microservice per container
These microservice deployment patterns were suggested by Chris Richardson on his blog, https://microservices.io/.
Let's now have a look at each strategy in detail.