Service Deployment Concepts Done
Service Deployment Concepts Done
Having read about Microservice Architecture, let us now understand how you can
deploy those microservices.
Packing services
Packaging Services
Every service might require a different set of dependencies for its
execution.
For example: App-1 requires Node-v6 and App-2 requires Node-v8 for its
proper execution.
One micro service might generate so much load and suck all the resources
of your machine, that the other microservices might die.
You can easily decorate the entire environment of the VM with all the libraries
and dependencies required by microservice, and deliver it as a single
image (Virtual Machine Image).
2 of 6
VM vs Container Technology
Container packages the application first then deploy them on servers. VMis created
first on the host machine; then applications are deployed on them.
Both containers and VMs are virtualization technology but they differ in few
areas:
OS: All containers share host machine's OS, while each VMs have their own
OS.
Load: Containers are lightweight, whereas VMs are heavy.
Security: Containers are less secured, whereas VMs are more secured
Portability: Docker containers are easily portable but with the same kernel's
OS as of previous host machine.
Deployment Strategies
Most common challenges while deploying your services to live production
environment, from the final testing stage are:
You can ensure safer deployments by reducing downtime and risks through
following strategies:
Blue-Green Deployment
Canary Releasing
Blue-Green Deployment
Else, if you are happy with the deployment, the Green continues to handle
traffic and the Blue environment is used for next version deployment.
Canary Release
In Canary Release, you will gradually roll out the new software to a group of
users, to verify it is working as expected. Once you are confident with the new
version, then you can gradually increase traffic to the new version by deploying it
to more servers of your infrastructure.
Deployment Patterns
There are different ways in which you can deploy your microservices:
Faster deployments: Just copy the service to host and run it.
Cons:
No isolation of service instance
In this pattern of deployment, you run single service on each server/host. There
are two ways of doing this:
Packing each service as VMI acts as a black box. This helps you
to encapsulate the service implementation technology.
Cons:
Less efficient in resource utilization.
Lightweight
Fast to build
Cons:
Less mature infrastructure than VM (rapidly increasing though).
Containers share the same kernel of host OS, which makes them less
secure than VM.
Serverless Deployment
Upload your services to public cloud service provider and run itwhenever you want.
Cloud service providers will take care of your (physical/virtual/containers) and other
requirements.
AWS Lambda
Azure Functions
Google Cloud Functions
Cons
Security issue might come as the server and resources are not in your
control.
As you do not control servers, you cannot install any monitoring software. You
will have to depend on tools from vendors for monitoring and debugging
your services.
On scaling up, the server might need some time before it could handle requests.
This problem is known as cold start.
Netflix uses AWS Lambda for managing their
AWS infrastructure.
Source
Which of the following strategy will not deploy new software to your users
at once?
A/B Deployment
Red-Black Deployment
Blue-Green Deployment
Canary Release
Installation Scripts
Deployment Tools
Installation Scripts
Only install the necessary software packages, generate configuration files and
create user accounts on your computer
Such scripts, when called repeatedly, might fail. For example, a script is called
to update configuration file or account that is already present in the
machine would fail, as they cannot be overwritten easily.
You can implement these using Shell scripts.
Deployment Tools
You can use other DevOps toolslike Puppet, Chef, and Ansible, to deploy and
configure your servers.
You can describe the desired state that your system is supposed to look after
installation.
Running the same installation (for example, Ansible script/playbook) multiple
times will not do any further changesto your system as the system is already in
the desired state.
You can easily configure multiple servers at the same time.
Wait, did you just wonder how microservices would communicate when they are in
isolation?
Synchronous Communication
Asynchronous Communication
Asynchronous Communication
In Asynchronous Communication, the client (you may think of your browser) sends a
message to a service, assuming it will not receive the reply immediately from service.
The client does not get blocked. Hence the user can continue other work.
Example: You can start ten message threads with your ten friends on Fresco Talk
and handle the response as they come in (async).
Cons
Response time is unpredictable.
It is more complicated as the client needs to match the response with the
request because the service response was not immediate and meanwhile the
client would have sent multiple requests to other services.
Synchronous Communication
In Synchronous Communication, the client sends a request to service and waits for
the service to respond immediately.
Example: In online bank transactions, you are not supposed to refresh website and
cannot do any other task on the page until the response comes
In short, the response is a must to proceed to next task in synchronous
communication.
Cons:
For long-running operations, user experience degrades.
Client and service should be available for the duration of the exchange.
Clients must know the location of the service instance, using service discovery.
Message Formats
These are two message formats that can be used to transfer data among
Microservices.
Istio
Let us look at one of the tools that implement service mesh.
Wrapping Up
Hope you had fun learning this course.
Think Tank
Before leaving a question to ponder:
Each microservice has its own private place to store data using SQL or
NoSQL database.
How can you maintain consistency and retrieve data from multiple services?
Sayonara!