Table of contents
No headings in the article.
**Before jumping to Microservice we should have to understand what is monolithic?**
A monolithic architecture is a common software design style where every program element is condensed into a single executable file. It is distinguished by having a single codebase that unifies all project functionality.
What is advantage and disadvantage ?
Advantage
- It is simpler to deploy using just one executable file or directory. *Finding the issue is relatively simple when all the code is in one file.
- Compared to microservices architecture, network latency and security issues are comparatively less of a concern.
- Developers need not learn different applications, they can keep their focus on one application.
Disadvantege
With time, it grows too big and is therefore challenging to maintain. Even a minor modification requires a complete application redeployment.
Even if a new developer's role is limited to specific functionality, it can be quite challenging for them to comprehend the logic of a huge monolithic application.
We must deploy instances of the complete application across numerous servers, even if only one section of it is experiencing heavy demand or traffic. It uses more resources needlessly and is incredibly inefficient.
In monolithic applications, horizontal scaling is therefore not possible.
What is Microservice?
It is an architectural development approach for deployment in which an application is composed of discrete services that each handle a small portion of functionality and data while communicating with each other directly, much like the HTTP protocol
Principles of microservices:
Single responsibility: It is one of the principles listed in the SOLID design pattern. It states that a single unit, such as a class, function, or microservice, should have just one responsibility. Each microservice must have a single duty and offer a single feature. You might also state that the number of microservices you should create is equal to the number of functions you need. Additionally, the database is decentralized, and often each microservice has its own database.
Design for failure: Failure cases must be considered throughout the design of microservices. Microservices must make use of this architecture's advantages, and if one microservice goes down, the whole system shouldn't be affected. The user must still have access to other features. Contrarily, in monolithic programs, the failure of one module does not result in the failure of the entire application.
Advantages of microservices:
it is relatively smaller, and it is easy to handle.
We just need to relaunch one microservice if there is an upgrade to one of the others.
Because of they are self-contained, microservices can be deployed separately. They have quicker deployment and start-up times.
The project is relatively simple for a new developer to join because he just needs to learn the specific microservice that is providing the functionality he will be working on, not the entire system.
Only that microservice has to be scaled out if it is under heavy pressure as a result of people abusing its functionality excessively. In light of this, the microservices architecture allows for horizontal scaling.
Depending on the needs of the organization, each microservice may employ a different technology.
When one microservice crashes due to a defect, it doesn't effect the other microservices, and the entire system is still operational and continues to offer users other functionalities.
Disadvantage
Microservices consume a lot of network resources since they must communicate with one another remotely, which increases network latency.
Because of network-based inter-service communication, microservices are less secure than monolithic applications.
With an increase in the number of microservices, their complexity rises.