Monolithic Architecture is like a big container, where all the software components of an app are created and tightly coupled, that is each component is fully dependent on the other. For example, you are developing an e-commerce site and there any many modules in it like the below image.
As you can see in the example all the services provided by the application (Customer Services, Cost Services, and Product Services) are interconnected. So if we want to change in code or something we have to change all the services as well. So now let’s deep dive into some challenges that we faced in Monolithic Architecture.
Problems/Challenges with Monolithic Architecture
Problems/Challenges 1:
Imagine you have a requirement right now, that in the course module, you want to have a new feature implemented. So to implement some new features or fix some bugs. Let’s say you want to add this new feature to the course module so that all courses will have this new theme or add a new button. So imagine you have been given some kind of sample requirements and you need to change them in the Course Module in order to add the new features.
So, you have made some changes to your code base in the Course Module and you push it to Git and the code goes to Jenkins and Jenkins picks up the code, creates a build and deploys it into the server and your application went live and you have tested your changes and you have seen the application is working as the client requirements. And the next morning, you got to know from the testing team that you have pushed some changes, and that basically broke the application. And whenever you asked them you got to know that the new feature is working fine but something is broken with the customer module. For example, the customers are not able to log into the application. So you got confused because you make changes in the Course Module but the effect is showing on the Customer module. But why so? Because the entire application is getting zipped together and getting deployed together on the server. So there are two problems over here
- Any changes in the code lead you to test the entire application.
- Developers may not have knowledge of all the modules and that’s making it harder to get started with any module and also fix any issues.
So basically the thing is that a developer who is working on one module might not have an idea of other modules. That’s why if you are working on a monolithic application in your company it might be very hard to get started with the application.
Problems/Challenges 2:
Now talk about another scenario. Let’s say the client has given you an offer let’s say every new user and customer will get 20% off in all the courses. Now what will happen is a lot of users will come and they are trying to log into the application by signing up and creating a new user account on the website. Now there are lots of loads coming into the Customer Module. In short, the Customer Module code will be mostly utilized. Now what happens is your Spring Boot or any application that cannot basically handle lots and lots of load coming into this module. And your website will be coming slow over here.
So right now what you can do as a solution you can take the same application which is running on server 1, you can put it on server 2, and can put it on server 3. Now same application same code you are putting in many servers and you are basically having your DB connected to all the servers. Right now the same code is running on three different servers. So, now our goal is whenever the request is coming, some request we will send to Server 1, some requests to Server 2, and so on. We also have a Load Balancer implemented and this load balancer will do what whenever the request will come it will route the request into the different servers to handle and balance the load.
Right now the same code is running in three different servers and this load balancer is basically routing the request to multiple servers in order to balance the load so that there will not be any burden or load into different servers that we have now. But what’s the problem here? The problem is here you can see in the above image we are having traffic in the Customer Module Only but right now just because the customer module is heavy we are ended up deploying the code into three different servers because the customer module is not independently deployable. So the point is we are only getting the load in the Customer Module but why to deploy the Employee Module, Course Module, and Address Module into different servers? This is unnecessary and the cost of the server is not that cheap. It’s a complete waste of both money and resource.
So here comes the Microservice Architecture to solve these major problems. Please refer to this article What is Microservice Architecture and Why to Use Them?