Monolithic vs. Microservices Architecture (Part 1)
In this tutorial, we are going to learn about Monolithic Architecture and Microservices deeper. Here we are focusing on these things,
- Why Micro Services
- What is Microservice Architecture
- Features of Microservice Architecture
- Advantages of Microservice architecture.
- Companies using Microservices
- Demo based on Microservices.
Before Microservices we all know there is an architectural pattern called Monolithic Architecture. There are certain advantages and disadvantages to this Monolithic architecture. Let me first explain that architecture. What actually Monolithic architecture means?
So basically all the components of the monolithic program are interconnected and interdependent. This will give you tightly coupled software where each component along with its associated components must be present in order to execute or compile the code.
So all of these components are dependent on each other. So if we notice the definition of Monolithic, this architecture is like a big container wherein all the software components of an application are assembled together and tightly packaged.
So if you notice below image there is a server-side application that executes the domain-specific logic.
It will retrieve data from the database and at the same time Views sends to the browser. So this basically a big container or I can say that it is not divided into small services and not divided into small components. So even these components are there pretty tightly coupled. So I give you a better example of what exactly Monolithic architecture is.
Let us discuss a classic example of an E-Commerce website. In the common e-commerce application, we can see the common options of Customer Service, Product Service, and Cart Service which a customer can access through their browser. And when you launch the application it is deployed as a single monolithic application. Only one single instance we can notice. When you deployed all these Cart services, Product service and Customer service it will be a single monolithic application. Now, what can you do? You can run multiple instances of this application behind the load balance.
Advantages of this architecture:
- Very simple to develop — It is very easy to develop a one-directional. Pretty simple to deploy because you need to deploy an executable file rather runtime to launch the application.
- Very simple to scale — In order to scale your application all you have to do is make multiple copies of the application behind the load balance.
Disadvantages of this architecture:
- Large and complex applications — If you have a large application it will increase the size of the application and it becomes very complex and hard to make changes to that application. And as a result, development slows down and modularity breaks down over time. So that it is difficult to correctly implement a change.
- Slow development — As your application and the respective team grow the application difficult to understand and modify. Because the application size is large and there are multiple teams are working. Also, large codebase leads to slow the IDE which affects the developer time.
- Unscalable — Different application components have different resource requirements. One might be CPU intensive while others might be memory intensive. In Monolithic architecture, we cannot scale each component independently. In our previous example if you have to increase only the customer service you can scale up the customer service. not only that you need to do that for other Product and Cart services too.
- Unreliable — In tightly coupled components if one of them goes down the entire system will fail to run. If my Product service failed that will lead to failing my entire application. Because all the modules are running in the same process a bug in any module potentially breaks down the entire process. Since all the instances of the application are identical bug will fail the entire application.
- Inflexible — It is very difficult to adopt new frameworks and languages. Suppose you have a million lines of code in the XYZ framework. Now it would be extremely expensive in terms of time as well as the cost to rewrite the entire application to use a newer ABC framework. So there is a huge barrier to adopting new technology.
Let’s learn about Microservices Architecture in the next tutorial.
Monolithic vs. Microservices Architecture (Part 2)
In this article, we are going to learn about Microservices Architecture. I think now you have a better understanding of…