Monolithic vs Microservices Architecture
This is the 1st post in a series on microservices architecture. This article is originally published at https://www.learncsdesign.com
It’s important to understand the pros and cons of both architectures. Let’s discuss them in detail.
Monolithic Architecture
We consider a monolithic system one in which all functionality is deployed in one go. There are two types of monolithic systems.
- Single process monolith — All code is packaged into a single process.
Single Process Monolith Architecture
2. Distributed monolithic — The system consists of multiple services, but for whatever reason, it must be deployed as a whole.
Distributed Monolithic Architecture
Pros of Monolithic Architecture
- Easy to develop and test.
- Deploys as a single deployment unit.
- Easily scale horizontally with the same deployment unit.
- Requires less technical expertise and sharing the same underlying code.
- Allows high performance by centralizing code and memory.
- Suitable for small applications.
Cons of Monolithic Architecture
- The complexity of a system increases with time.
- New features take a long time to be released.
- Production hotfixes take longer.
- When a small change occurs in a module, the entire application has to be updated.
- Unable to adopt newer technologies for better performance due to their close relationship with one technology.
- Single point of failure.
- Code becomes complex and doing KT becomes increasingly challenging due to high coupling.
- High dependency on key developers who understand the entire code base
- Continuous deployment is challenging.
- Individual modules are difficult to scale.
- The high coupling between modules causes reliability and availability issues.
- Security concerns as all deployment are at one place.
Microservices Architecture
The concept of microservices refers to independent, deployable services attached to a particular business domain. Microservices communicate through networks. The microservice architecture consists of multiple collaborating microservices and is a form of service-oriented architecture (SOA).
Microservices are small Autonomous services that work well together, modeled around a business domain.
— Sam Newman
The fundamental characteristic of microservices is their agnosticism toward technology. Using one or more network endpoints, microservices expose the business capabilities that they encapsulate. They also encapsulate data storage and retrieval, exposing data via well-defined interfaces, making them a form of a distributed system. Databases are therefore hidden inside the service boundary. Let’s examine these concepts in more detail.
Independent Deployability — The idea is that we can make a change to a microservice and deploy it into production without having to use any other services. Our services need to be loosely coupled to ensure independent deployment.
Modeled Around a business domain — Each service caters to only one subdomain of business needs and is responsible for that subdomain. Microservices should adhere to the Single Responsibility Principle (SRP).
Own their own data — When a microservice needs access to data held by another service, it should ask that service for the data. Microservices should not share databases.
Pros of Microservices
- Domain knowledge and business expertise.
- Independent scalable.
- Accelerates the velocity of software development by enabling small, autonomous teams to work in parallel.
- The ability to respond quickly to change.
- Improves uptime.
- Adapt newer technology more easily.
- Loose coupling.
- Ideal for large-scale applications.
- Clearly defined team ownership of microservices.
- Customizable security for different services.
Cons of Microservices
- Distributed systems introduce additional complexity.
- Deployment complexity.
- Monitoring is more complex.
- Increasing resource consumption and lots more servers to manage.
- Network communication between distributed services is not instantaneous and may result in latencies.
- Testing services can be challenging.
- Data consistency between services is challenging and complex.
Below are links to posts that explain each pattern in more detail.
1. Monolithic vs Microservices Architecture
2. Microservices Design Principles
3. Microservices Design Patterns
4. Microservices Decomposition Design Patterns
5. Microservices Data Design Patterns
6. Microservices Communication Design Patterns
7. Microservices External API Integration Patterns
8. Microservices Observability Design Patterns
9. Microservices Service Discovery Design Patterns
10. Microservices Cross-Cutting Concerns Design Patterns
11. Microservices Security Design Patterns
12. Microservices Deployment Design Patterns
If you like the post, don’t forget to clap. If you’d like to connect, you can find me on LinkedIn.