What is microservice architecture in simple words?
As our users and business needs grow, we need to organize our code in a more structured and isolated way. This emerged the concept of “microservices architecture”.
What is the microservice architecture?
In a nutshell, microservice splits your business components into independent or loosely coupled services.
Monolithic architecture, in contrast, jams all your components together.
To make it clear, imagine you want to create an e-commerce website. At first glance, your main components are “Orders”, “Products”, “Users”.
If you want to go with the monolithic approach, then all of your components will be served in one service. What does that mean? It means if you want for example add a feature related to “Orders” component, you need to go throughout the all code base and add the feature. However, chances are other components will be affected by this change, so you should be wary of changing any piece of code by this approach.
On the other hand, if you go with the microservices approach, all of your components are going to get their individual code base and will be isolated from other components. What does that mean? It means if you want for example add a feature related to “Orders” component you need to go through one code base, the “Orders” service code base, instead of all of them.
As you can understand, the primary characteristics of the microservice approach are having isolated, independent loosely coupled services. This means changing to one component should have no or little impact on other components.
What are the cons and pros of each architecture approach?
Every decision has its own trade-offs and these approaches are not the exception. I’m going to point out the major cons and pros below.
The major advantage of the microservice architecture relies on its ability to make you have an isolated framework. This is a good bet since it gives you the ability to safely work on individual components without affecting other components. So, you as a manager can divide your team to work on individual services rather than one-team-for-all style.
The major drawback of microservice architecture relies on the complexity that it brings into the table. To understand it better, consider that every service should be able to communicate with each other service and provide necessary information for individual services if needed. Believe me, it is more complex than it seems.
Monolithic architecture is way more common in small to medium projects and it is simpler in comparison to microservices. But if you have a large-scale business, with many components it is an overkill approach to go with. Since every change to the code has the potential to bring your whole code down!
Which one should be chosen over another?
If you are going to start a new project from scratch then the monolithic approach is your best friend. It is simpler and easier to understand which protects you from pre-optimizing unnecessary needs and prevents you to deal with the complex decision from the start.
As you progress, then you can decide whether you should change your architecture or not. This decision is so costly in terms of refactoring the current code base to the microservice code base so it should be analyzed and discussed carefully before taking any action.
Thanks for your reading, I’m going to post some other article related to microservices in the future and link them here. you can motivate me better to write them sooner by clicking the clap button.