Microservices vs Monolithic Architecture
In the world of programming, two architectures remain predominant namely monolithic and microservice-based architecture. Regardless of the adopted structure, the main goal is to design an application that delivers value to customers and can be easily adjusted to accommodate new functionalities.
- Monolith: application design where all application tiers are managed as a single unit
- Microservice: application design where application tiers are managed as independent, smaller units
Also, each architecture encapsulates the 3 main tires of an application:
- UI (User Interface) — handles HTTP requests from the users and returns a response
- Business logic — contained the code that provides a service to the users
- Data layer — implements access and storage of data objects
DECIDING FACTORS :
- Development complexity represents the effort required to deploy and manage an application.
- Monoliths — one programming language; one repository; enables sequential development
- Microservice — multiple programming languages; multiple repositories; enables concurrent development
2. Scalability captures how an application is able to scales up and down. based on the incoming traffic.
- Monoliths — replication of the entire stack; hence it’s heavy on resource consumption
- Microservice — replication of a single unit, providing on-demand consumption of resources
3. Time to deploy encapsulates the build of a delivery pipeline that is used to ship features.
- Monoliths — one delivery pipeline that deploys the entire stack; more risk with each deployment leading to a lower velocity rate
- Microservice — multiple delivery pipelines that deploy separate units; less risk with each deployment leading to a higher feature development rate.
4. Flexibility implies the ability to adapt to new technologies and introduce new functionalities.
- Monoliths — low rate, since the entire application stack might need restructuring to incorporate new functionalities
- Microservice — high rate, since changing an independent unit is straightforward
5. Operational Cost represents the cost of necessary resources to release a product.
- Monoliths — low initial cost, since one code base and one pipeline should be managed. However, the cost increases exponentially when the application needs to operate at scale.
- Microservice — high initial cost, since multiple repositories and pipelines require management. However, at scale, the cost remains proportional to the consumed resources at that point in time.
6. Reliability captures practices for an application to recover from failure and tools to monitor an application.
- Monoliths — In a failure scenario, the entire stack needs to be recovered. Also, the visibility into each functionality is low, since all the logs and metrics are aggregated together.
- Microservice — In a failure scenario, only the failed unit needs to be recovered. Also, there is high visibility into the logs and metrics for each unit.
Summary
An application can be designed using both, monolithic or microservice-based architectures.