The Difference Between Monolithic and Microservices Architecture
Post Date : 2023-09-22T15:52:14+07:00
Modified Date : 2023-09-22T15:52:14+07:00
Category: systemdesign microservice-architecture
Tags:
Monolith advantages and drawbacks
A monolithic architecture is a traditional software development model that uses one code base to perform multiple business functions.
Advantages of Monolithic Architecture
-
Simplicity of development : all source code is located in one place which can be quickly understood.
-
Simplicity of debugging : The debugging process is simple because all code is located in one place. You can easily follow the flow of a request and find an issue.
-
Simplicity of testing : You test only one service without any dependencies. Everything is usually clear.
-
Simplicity of deployment : Only one deployment unit (e.g. jar file) should be deployed. There are no dependencies. In cases when UI is packaged with backend code you do not have any breaking changes. Everything exists and changes in one place.
-
Simplicity of application evolution: Basically, the application does not have any limitation from a business logic perspective. If you need some data for new feature, it is already there.
-
Cross-cutting concerns and customizations are used only once: You should take care of cross-cutting concerns only once. For instance, security, logging, exception handling, monitoring, choosing and setting up tomcat parameters, setup of data source connection pool, etc.
-
Simplicity in onboarding new team members: The source code is located in one place. New team members can easily debug some functional flow and to get familiar with the application.
-
Low cost in the early stages of the application: All source code is located in one place, packaged in a single deployment unit, and deployed. What can be easier? There is no overhead neither in infrastructure cost nor development cost.
-
The main function of the application is to be profitable: As a result, it is important to quickly implement some POC (Proof of Concept) solutions to verify the application in the real world. Also, it is important to bring customers to the system. Improvements can be implemented in the future.
-
The requirements are usually unclear at the early stages of development: It is hard to create meaningful architecture when the requirements are unclear. Real customers can define the business needs after some of the functionality already works.
Drawbacks of Monolithic Architecture
-
Slow speed of development: The simplest disadvantage relates to CI/CD pipeline. Even a small change in source code, you may wait for a lot of time (e.g. 1 hour) for your pipeline to succeed.
-
High code coupling: Of course, you can keep a clear service structure inside your repository. However, as practice shows, eventually, you will end up with a spaghetti code in at least a few places.
-
Code ownership cannot be used: The system is growing. The logical step is to split responsibilities between several teams.
-
Testing becomes harder: Even a small change can negatively affect the system. As a result, the regression for full monolithic service is required.
-
Performance issues: Potentially, you can scale the whole monolithic service in cases of performance issues. But what to do with the database? The single database is used for all services. You can start to optimize your database queries or use read replicas. However, there is a limit to this type of optimization.
-
The cost of infrastructure: In cases of performance issues, you should scale the whole monolithic service.
-
Legacy technologies: Imagine that you have the application written on Java 8. How much time is it required to migrate the whole monolith with multiple services.
-
Lack of flexibility: Using Monolithic Architecture you are tight to the technologies that are used inside your monolith.
-
Problems with deployment: Even a small change requires the redeployment of the whole monolith.
Microservices advantages and drawbacks
Microservice Advantages
-
Self-Contained, lower costs and increase efficient: Each service has its own instances. So when you need to scale up for specific service, the cost compare to monolithic architecture is actually lower.
-
Greater Agility and Flexibility in Development process: each team develop their service autonomous and dependence, so they can select the appropriate tech stack and deployment flow.
-
Enhance new technology stacks
-
High costs at early stage, but easy for upgrading and maintenance.
-
Development, Debugging, Testing each service become more easier
Microservice Drawbacks
-
Increase Development Time
-
Difficult in Global Testing and Debugging
-
Dependency on Devops
-
High Complexity
-
Increase Network Traffic
-
Limited Reuse of Code
-
Problems with deployment
-
Have all properties of a distributed system.
Challenges
- Design for Faults
- Design with Dependencies in Mind
- Design with the Domain in Mind
- Design with Promises in Mind
- Distributed Systems Management