Pages

December 04, 2019

Part 13: Microservices (Deployment Patterns)

Deployment Patterns
  • Multiple service instances per host - deploy multiple service instances on a single host
  • Service instance per host - deploy each service instance in its own host
  • Service instance per VM - deploy each service instance in its VM
  • Service instance per Container - deploy each service instance in its container
  • Serverless deployment - deploy a service using serverless deployment platform
  • Service deployment platform - deploy services using a highly automated deployment platform that provides a service abstraction
Multiple service instances per host pattern

In this pattern we run multiple instances of different services on a host (Physical or Virtual machine). There are various ways of deploying a service instance on a shared host including:
  • Deploy each service instance as a JVM process. e.g, a Tomcat or Jetty instances per service instance.
  • Deploy multiple service instances in the same JVM. For example, as web applications or OSGI bundles.
The drawbacks of this approach include:
  • Risk of conflicting resource requirements.
  • Risk of conflicting dependency versions.
  • Difficult to limit the resources consumed by a service instance.
  • If multiple services instances are deployed in the same process then its difficult to monitor the resource consumption of each service instance. Its also impossible to isolate each instance.
Single Service Instance per Host
In this pattern, we deploy each single service instance on its own host. The benefits of this approach include:
  • Services instances are isolated from one another
  • There is no possibility of conflicting resource requirements or dependency versions
  • A service instance can only consume at most the resources of a single host
  • Its straightforward to monitor, manage, and redeploy each service instance
The drawbacks of this approach include is potentially less efficient resource utilization compared to Multiple Services per Host because there are more hosts.

Service Instance per VM
In this pattern each service is deployed as a set of service instances for throughput and availability. Package the service as a virtual machine image and deploy each service instance as a separate VM. The benefits of this approach include:
  • Its straightforward to scale the service by increasing the number of instances. Amazon Autoscaling Groups can even do this automatically based on load.
  • The VM encapsulates the details of the technology used to build the service. All services are, for example, started and stopped in exactly the same way.
  • Each service instance is isolated.
  • A VM imposes limits on the CPU and memory consumed by a service instance.
The drawbacks of this approach is building a VM image is slow and time consuming.

Service instance per container
In this pattern we package the service as a (Docker) container image and deploy each service instance as a container. The benefits of this approach include:
  • It is straightforward to scale up and down a service by changing the number of container instances.
  • The container encapsulates the details of the technology used to build the service. All services are, for example, started and stopped in exactly the same way.
  • Each service instance is isolated.
  • A container imposes limits on the CPU and memory consumed by a service instance.
  • Containers are extremely fast to build and start. Docker containers also start much faster than a VM since only the application process starts rather than an entire OS.
The drawbacks of this approach include is the infrastructure for deploying containers is not as rich as the infrastructure for deploying virtual machines.

-K Himaanshu Shuklaa..

No comments:

Post a Comment