# Introduction to Microservices Tech
01 October 2022
Disclaimer
Information may not be theoretically correct. I am writing this with my own knowledge and experience
# What are Microservices?
Microservices are those services which satisfy following criteria:
- Independently Developed
- Independently Deployed
- Independently Testable
- Independently Scalable
- Independent Database
If any of the criteria fails, you have a monolith instead of a microservice
NOTE
A typical tech company can have more than 150+ microservices running
# Monolith vs Microservices
Monolith is a traditional concept where all code resides in one single codebase ie one repository. The structure of code may be modular but the whole code is developed, deployed, scaled at once.
- All codebase resides in one single repo in Monolith, while each Microservice has its own codebase repository.
- All services in Monolith is deployed at once, while in Microservices each can be independently deployed.
- Monolith scales are services equally, you cannot independently scale services according to individual need, while Microservices are individually scalable.
- Monolith has one single database, while each Microservice has its own database context or independent database.
# Case Study
# Order Management System
A typical order management system can have following core modules:
- Login
- Inventory
- Order
- Email, Notifications
- Reports
If we decide to go by Monolith initially, soon we shall encounter following issues
- High coupling chances between different services code. This typically appears when your developers are little beginners.
- A lot of boilerplate code in one single project.
- Abstraction principle not properly followed.
- Heavy reports generation causes large resource consumption.
- SPF (Single Point Of Failure) is high. If any of module code breaks whole server will be down.
- More sprint release time required. Cannot publish minor changes in between.
Microservices way
We can easily break this Monolith into different domain Microservices each assigned with a single responsibility. The Microservices will be:
- Login - Responsible for Authentication/Authorization system
- Inventory - Responsible for managing inventory and adjustments
- Order - Responsible for order creation, dispatch, cancel
- Email, Notifications - Responsible for notifying users about order, updates, promotions
- Reports - Responsible for getting different excel reports