Microservices Introduction
Nowadays Microservice is the buzzword. Being a newbie a have heard it many times. I spend last week understanding this. Allow me to share what I have learned so far.
What is Microservices?
It is a new architecture for developing a web application.
What we had before this?
Before Microservice architecture people used to follow monolithic architecture. Mono means one and lithic means stone. It means the whole application is inside one box where the whole works as an independent entity. For readability, developers use to divide it into multiple modules but these modules were not independent.
A monolithic architecture is the traditional unified model for the design of a software program. Monolithic, in this context, means composed all in one piece. According to the Cambridge dictionary, the adjective monolithic also means both too large and unable to be changed.
Microservices architecture
In this, we divide the whole app into the smaller independent self-sufficient unit and these units are known services. These services talk to each other whenever required.
Advantages of Monolithic architecture
- Simple to develop.
- Simple to test.
- Simple to deploy.
- Simple to scale horizontally by running multiple copies behind a load balancer.
Disadvantages of Monolithic architecture
- Tight coupling between components, as everything is in one application.
- Less reusability.
- Large code base, tough for developers and testers to understand the code and business knowledge.
- Less Scalable.
- Does not follow the Single Responsibility Principle.
- More deployment and restart times.
Advantages of Microservice architecture
- Independently deployable and allow for more team autonomy.
- Independently scalable.
- Reduce downtime through fault isolation.
- The smaller codebase enables teams to more easily understand the code, making it simpler to maintain.
Disadvantages of Microservice architecture
- It has all the associated complexities of the distributed system.
- Higher chance of failure during communication between different services.
- Difficult to manage a large number of services.
- Network latency and load balancing.
Conclusion:
Both architectures have their own pros and cons. Its the job of the developer to decide which architecture should be used depending upon the requirements.