Principles of Microservices
Principles of Microservices
Microservices
10 TH SEP 2017
Abstract
There are multiple strategies to transform a system estate into an estate that is
faster to deliver new features, easy to maintain, cost-efficient and robust. Of the
many architectural styles for digital transformation, the architectural style that
is getting a lot of attention in recent years is 'Microservices’. This style is not
completely new; it is a type of distributed architecture that has evolved from
component-based architecture and service orientated architecture. It can be
viewed as a specialisation of the overall service orientated architecture
paradigm.
2
Principles of Microservices
It is important to note that this provides only an indication of the team size and
it should not be followed blindly. It is more important to understand the
rationale of relating the size of Microservices to team size. The objective of
having small teams, is to maintain focus and develop a sense of ownership of
the component end to end which includes implementation and monitoring of
the business function. There can be larger teams managing more complex
business functions or smaller teams managing simpler business functions.
The objective of all of the above approaches is to define the scope of business
function such that it has a minimal dependency on other services and thus
reducing the need to build integration points between functionality that is
intrinsically cohesive.
5
Principles of Microservices
Abstraction and encapsulation enable the creation of two 'Worlds'. The internal
world of the Microservice and the external world that the Microservice interacts
with. The internal world has the freedom to manage its design and operations.
It has the freedom and independence to choose how it should implement a
business function. It can choose the technology, database and language best
suited for its business function and not depend or be influenced or inhibited by
the technology choices of other services. This ensures that the Microservice is
extendable to support future requirements.
6
Principles of Microservices
Microservices uses the concept borrowed from the internet of having smart
endpoints and dumb pipes. The business logic and functions are moved from the
integration layer to the components. This keeps the integration layer thin
focusing on technical integration functions such as service registry, discovery,
message routing, API composition, and protocol translation and security. This
ensures extendibility and scalability.
A key disadvantage is that there is very little separation of the service instances
unless each service instance is modelled as a separate process. A service
instance can consume all CPU and memory of the host.
Deployment on Host
In this pattern, each service instance is deployed on its host. There are two
specialisations of this pattern
4. Deployment on VM
5. Deployment on Container
7
Principles of Microservices
Deployment on VM
In this pattern, each service is packaged as a virtual machine image. Each service
instance is created as a VM and is launched using that VM image. The key benefit
is that each service instance runs in isolation on its own VM. The amount of CPU
and memory is fixed per VM and cannot use resources from other services.
Another advantage of deploying the service as a VM is that it encapsulates
service instance implementation details. Once a service has been packaged as a
VM it can be viewed as a black box.
The key disadvantage is less efficient resource utilisation. Each service instance
has the overhead of an entire VM. Another disadvantage of this approach is that
deploying a new instance of a service is usually slow. VM images are slow to
build due to its size.
Deployment on Container
In this pattern, each service instance is deployed on its container. A container
consists of multiple processes running in a sandbox. The advantages of
containers are similar to VMs, but it is much lighter. It isolates service instances
from each other. Container images are very fast to build.
Serverless Deployment
In this pattern, the service instance is deployed to a Function as a Service like
AWS Lambda. The key benefits are the cost since you only pay for what you use
and not pay for any idle time. The key disadvantage is cold start, which is latency
experienced after function is triggered.