Monolithic vs Microservices Architecture
TL;DR. Basically, it’s easier to split into many than combine into one. So, just start with monolithic architecture for building simple and lightweight application. Then recognize the conditions that indicate we should migrate into microservices architecture.
Monolithic Architecture
Definition
Monolithic architecture is a traditional software development approach where the entire system function will be compiled into single application, so that the application runs all the required processes. In monolithic architecture, the application doesn’t depend on other application and doesn’t require API for communication between its components.
Generally, each application consist of three layers: presentation, business logic and data access layer. These layers build in a stack that are interrelated to build particular component or process.
In a single application monolithic, of course there can be many components related with it. Such as authenticator, notification manager, reporting component, scheduler, formatter, other components, etc.
Advantages
Monolithic architecture has many benefit, such as:
- Simple to develop. With a single application in place, of course fewer concerns with session, caching, memory management and allocation, etc.
- Simple to test. Since it is a single application, it is easier to perform automated testing and debugging, without taking into different run-time environments.
- Simple to deploy. Just have to upload the latest packaged application into server.
- Simple to scale out. Just running multiple copies behind a load balancer.
- Simple to trace. Monolithic application does not involve API, Messaging, or Event for the communication between components, which means flow process clearly described.
Disadvantages
Monolithic architecture has also many drawbacks, such as:
- Difficult to understand. Application is too large and complex to fully understand, especially for newcomers.
- Extremely low scalability. Scaling can only be done as a whole application, because the scaling of individual components is not possible.
- Difficult to continues deployment. Have to redeploy the entire application on each update.
- Tight coupling. Single application handle all required process or services, so codebase become much more complex as the application grow.
- Single point of failure. If any bug or something goes wrong in a single component or process, it could bring down the entire application.
- Potentially stagnant. Monolithic architecture has a barrier for adopting new technologies. Since changes in frameworks or languages will affect an entire application.
Microservices Architecture
Definition
Microservices architecture is a software development approach based on larger application build as a collection of small, lightweight, and single-purpose stand-alone units component. Each component is a small application has its own architecture consists of business logic, encompasses its own data, with no dependencies on other components. Those components (called as microservice) can communicate each other using REST API, RPC, Messaging Queueing, etc.
Advantages
Microservices architecture has many benefit, such as:
- Faster development. Keep it small and lightweight to make teams focus to build and test specific system elements. It also easier to understand, easier to maintain, easier to troubleshoot when issue production occured.
- Independent deployment. No need to redeploy the entire application on each update, just redeploy specific component. Continues deployment is possible for complex applications.
- High reliability. A failure in one component will not cause other component (moreover entire system application) malfunction.
- Scaled independently. Using container platform technology, each component can be scaled out and scaled up easily and independently.
- Reusable modules. Each component can be reused and reprofiled for other purposes and tasks.
- Agility. Microservices architecture reduces barrier of adopting new technologies since the developers are free to choose whatever technologies make sense for each component.
Disadvantages
Microservices architecture has also many drawbacks, such as:
- Distributed system design is challenging. By the fact that a microservices application is a distributed system, we need to choose an inter-process communication mechanism for each component to handle partial failure.
- Increased operational complexity. With the increased number of modules comes higher operational complexity and the deployment process becomes more convoluted.
- Testing become more complex. For a similar test for a service, we need to launch that service and any services correlated with.
Head to Head Comparison
Conclusion
At the beginning, it is much easier to go with monolithic architecture since it is simple to do the development. It is simple to test, and it is simple to deploy. But this simplicity approach has a lot of limitation in size and complexity. When application getting bigger and bigger, split the application into a set of smaller and interconnected services, which is well known as microservices architecture.
References
[1] Bhanuka Dissanayake, Monolithic vs. Microservices Architecture, 2019.
[2] Rich Marshall, To Monolith or to Microservice, 2020.
[3] Veselin Mijuskovic, Monolithic VS Microservices: Which App Development Architecture To Use, 2021.