
What is a Microservice?
The need to break the big monolithic applications that can be compared as a building built from ground up with no separate distinguishable parts in fully functional separate parts.
There came a need to divide these big monolith applications into small independent modules
These modules are developed, tested & deployed independently as a separate service
And these individually deployed services are called microservices
To cite an example, a traditional web application for a company uses one application or code base and handles self service login, inventory availability, pricing, shipping into all one app.
Microservice architecture can break them into independent functions like pricing is a separate engine, inventory availability could be a separate application independent of other apps etc.
Service Directory - This concept means that the service directory lists all the micro services and based on the request from the gateway, it will pick the right micro service to perform a job.
Gateway Service - It acts as an external wrapper to all microservices - It is a single door to communicate with all microservices - Request from frontend applications always comes to the gateway service - It performs a basic authentication checks, & other security-related checks, etc.
Later it forwards to the respective microservice using service discovery - The microservice process the request, and send a response back to the gateway service and it is forwarded to the client

How Microservice Works?
- Here's a very simplified diagram to understand the internal working of Microservice Architecture:
The picture above shows the following events:
1) Request from the client machine front-end, goes to API gateway
2) API gateway performs authentication & other checks and asks Service discovery for the address of the respective microservice
3) Request goes to the microservice
Microservice communicates to the Database (if required) and then computes the response.
5) Response is sent to the API gateway
6) API gateway adds any additional headers (if required) to the response and sends it to the client.
Benefits of Microservice
- It is highly scalable, maintainable and modular in nature - Based on the need in a specific module we can use an altogether different tech stack. Hence use different programming languages as per their strength in one product. i.e. Java with Python
When to choose it?
- When your application is very complex and making any change to your application means a potential severity 1 issue.
- When you need to selectively scale different modules of your application. This means if you want to expand one specific module to another geography, you don't need to redo complete application development.
- You want to use different programming languages to their strength.
- When you move to cloud infrastructure using microservices will provide a flexible architecture and use the services when needed.
- It can be also used in a situation when the existing web services have become bloated and takes a lot of space/bandwidth with unnecessary data/payload. This is one way to make your web services more lean.
ABOUT
This is Mohammad Parwez. Welcome to my blog. I am passionate about real estate and technology.
Created with ©systeme.io