What is it?
Single application built as suite of small services which have following characteristics:
- Loosely coupled
- Communicating lightweight protocol
- REST etc
- Each running as independent processes
- Separately written, deployed, scaled
Is it SOA?
Not SOA, you can say a variant of SOA. SOA: talks about integrating various enterprise applications.
Microservices: decomposing single application into suite of smaller applications.
What are Monolithic Applications?
Consider you have a E-commerce application with following functionalities:
- Product Catalog
- Inventory management
- Shopping cart
- Payment Management
- User Management
- Order Management
Now if you create it as a monolithic application, you will create a single service (app) that provides all the required functionalities.
Ok, so what are the disadvantages of the Monolithic?
Here are few disadvantages:
- Locked to technology/language
- An entire app is written with a single tech stack, hence changing the tech stack will become a big task
- Cannot experiment/take advantage of emerging technologies, you are stuck with the initial tech you use.
- Difficult for a single developer to understand complete code
- Generally, a big team is working on the entire app, hence you will have to deal with numerous issues during merges and merge conflicts.
- The single app is generally connecting to multiple databases, loaded with validations and business logics, hence becoming complex.
- Changes of one functionality are held back by other changes.
- You can’t release your changes till other functionalities are done and tested.
- If there is a bug in other functionality, you can’t release your functionality.
Are there any advantages of Monolithic applications?
- Easy to test as a single unit.
- Easy to deploy as a single unit.
- Easy to scale.
- Easy to manage changes.
- Easy to manage versions.
How will you create the same e-commerce app in the Microservices world?
What are advantages of micro-services?
- Faster Delivery:
- Less code to change
- Less code to test
- Easy deployment steps
- We can scale individual services based on their use
- Easily understood:
- Since microservice size is small, a person or team can easily understand in and out of microservice
- Technology/language advantage
- Different process different technology
- If we have to change tech or language from java to python, it is small module for which we have to change
- Change cycle decoupled
- Each functionality or micro-service can be deployed when
- Culture: Well defined ownership, hight trust in team
- Easy deployment steps
- Isolation: Single microservice cannot crash entire system
- Flexibility: Polygot services, own persistence system etc
Are there any challenges of micro-services?
You have to take care of:
- So many services to manage.
- More monitoring required.
- Design for failures
- Remote calls vs in process call speed
- Transactions which goes over multiple services
- Sometimes features spans multiple services
- Multiple services required to be tested together
- Version management