Introduction:
In software architecture, our famous lovers Romeo-Juliet are being separated and the reason being not families but debate over the best architecture for running applications. Romeo supports Monolithic and Juliet supports Microservices.
In this blog we will dive deep into the dramatic world of software architecture, understanding each difference, advantages and disadvantages as the debate continues.
Who is correct? Who is wrong? Let's find out.😁
Monolithic:
Romeo:'Mono' refers to a single meaning, in this type of architecture the entire functionality of the project exists in the single code base. Here we design our application in various layers like presentation, service, and persistence and then deploy that codebase as a single jar/war file.
Example: Many small-scale applications with not many users like: local Gym websites or local Grocery.
🤔Did you know: Netflix's streaming service began as a monolithic application? Over time, they transitioned to microservices, but they still have legacy monolithic systems.
In simple terms imagine a small Restaurant where cooking, serving, managing groceries, billing and delivering are completely done inside one big building/container.
Microservices:
Juliet: 'Micro' means many or small. In this architectural method, we break down an entire application into smaller, many services. Each service provides its own functionality.
These services are developed, deployed, and maintained by a small team of developers. And all are independent of each other. Every service has its own separate Database of its own.
Examples: Netflix, Uber, Hotstar etc
Netflix: Netflix is a prominent example of a microservices architecture. Different microservices handle user authentication, content recommendation, billing, and streaming.
Imagine running a big restaurant where each part of the operation functions as an independent building. The kitchen is housed in one structure, the dining area has its own space, and there's even a separate building for the cashier and management office.
Let's both put our concepts visually and compare.
J: I understand a bit about Monolithic but doesn't it become difficult to manage the codebase, what about deployment?
Let's see some advantages and disadvantages of it.
Advantages of Monolithic:
Simple to build🏗️ the application.
Deploying🛫 is easy since only one jar/war file.
As everything is present in a single codebase no need for networking hence no problem of networking in between functionalities hence no latency problem.
Latency is a measure of the time delay between the initiation of a request or action and the moment when it is completed. It is often used in the context of networks and computing systems to describe the delay experienced during data transmission or processing.
Unlike Microservices, There is no duplication of the Data taking place since only one Database is present.🙂
J: But I see many Disadvantages too like:
Disadvantages of Monolithic Architecture 🙅:
Changes made in one module or one part may affect the other modules too since everything is packed as one. Which makes developers test and run entire applications even for small changes made in some modules. Re-deploy the entire application for small changes.
When the application gets too large then managing is very difficult 😅.
Understanding the codebase is very difficult for newcomers or Junior developers. They need to study the entire architecture even though they have small roles🥸.
Individual services cannot be scaled📈, scaling can be done for the entire system.
Ex: I have a website that connects sellers and buyers. If for some reason sellers increase rapidly then we need to scale the entire application. We cannot scale only the Buyers module.
We need to scale the entire system which makes it a waste the resources and managing is a tedious task.
Here, just to balance the buyer module we need to deploy the entire application on many servers.
R: Well there are many advantages of Microservices.
Advantages of Microservices🙉:
Since independent services Managing them becomes quite easier😃.
Unlike Monolithic, Easy for new developers to work since there is no need to study the entire codebase or architecture. Developers can work on their specific modules only.
If a new update is made in any of the modules only the specific service is deployed. No need to deploy the entire application.
Scalability is more flexible in a scenario where the load increases in just one module. In this case, you can scale each module individually without the necessity of scaling the entire application.
Independent services deployment time is also less.
If a particular microservice goes down due to some bug, then it doesn’t affect other microservices and the whole system remains intact and continues providing other functionalities to the users.
A Set of different technologies can be used to develop the entire application.
R: But with many advantages also come major disadvantages like:
Disadvantages of Microservices🫥:
Since individual services are present there is a need for networking among the services. These networks come with their own set of problems like security and Low Latency issues.
Being a distributed system the complexity of the system and designing architecture is very Difficult.
Requires highly skilled developers to maintain architecture.
Debugging is complex.
Testing the entire application can be complex since all services should work seamlessly
There is a duplication of data occurring. Since every individual service has its own separate Database some amount of data is duplicated.
Implementing a Load balancer to manage the Requests is complex and requires highly skilled developers.
A load balancer is a device or software that evenly distributes network traffic across multiple servers to ensure optimal performance and availability. It basically acts as Traffic police for requests.
So both of them have their own advantages and disadvantages and there is no one-size-fits-all solution. The winner of the debate is both 👏🙂. Both have a clear understanding of both architectures now and here there is no best approach.
Ha!! There are some parameters to consider before selecting the architecture:
Application size: Projects whose size is small and have less resource availability can opt for Monolithic, whereas applications that have complex systems and huge resources opt for Microservices since they cost much time, effort and cost.
Knowledge and skill set: Both of the architectures demand different sets of skill sets and knowledge and purely depend on Team competence and their practices.
Infrastructure: A monolithic application runs on a single server, but microservices applications benefit more from the cloud environment.
Scalability: Microservices are used where the business where customers are in masses and need to keep growing.
Romeo: Every developer has worked on Monolithic architecture at least once. But what are some rules that define Microservices⁉️🤔
Juliet: That's a brilliant question. Here are some points that will bring some clarity on the plate.😌
Principles of Microservices🤖:
Single Responsibility:
Every individual service has only one single functionality to perform according to a single responsibility. Hence depending on responsibility services increase.Built around business capabilities:
In today's world many different technologies and innovation arises Microservices play an important role as they do not restrict themselves and are Flexible.Design for failure:
Microservices must be designed with failure cases in mind. Microservices must exploit the advantage of this architecture and going down one microservice should not affect the whole system.
Congratulations on reading the blog👏.
Feel free to add some points on the topic and Feedback is appreciated
.
What application have you used? On whose the side are you, Romeo or Juliet??