System Architecture

Here we discuss the monolithic architecture, which is a tightly-coupled software running on a single physical server or Virtual Machine (VM) that handles the end-to-end workflow. Then we talk about the microservice architecture, which consists of many services running independently on different servers and connected via a network.

Monolithic

The monolithic architecture is about building a system as a single, indivisible unit. All components of the system are tightly coupled.

Because the components reside in the same place, it has several benefits:

This architecture well fits the use case like building a prototype. However, as time goes by and the application grows bigger in terms of number of features and users, certain drawbacks gradually emerge:

These downsides bring us to another architecture, microservice, which is the foundation for distributed systems.

Microservice

The microservice architecture breaks down the application into small, loosely coupled, independently deployable microservices. Each service is responsible for a specific business functionality and communicates with other services through APIs.

The microservice architecture addresses some of the pain points of the monolithic architecture:

However, just like a coin has two sides, the microservice architecture overcomes the monolithic architecture's shortcomings, but struggles to match the monolithic architecture's strengths:

CAP theorem

The CAP theorem focuses on the consistency, availability, and partition tolerance tradeoff of the microservice architecture. It says we can only achieve two out of the three guarantees at any given time:

In the microservice architecture, partition tolerance is a requirement because network failures happen all the time, so we have to choose between consistency and availability.

Troubleshooting

Because the microservice architecture brings in the time dimension complexity, we have to deal with race condition issues besides the common misconfiguration or Out-Of-Memory (OOM) issue.

Tradeoff

To sum up, the microservice architecture provides good:

But faces challenges for:

When choosing the architecture for our system, it all comes down to the question: which set of metrics matters?

If our product needs high availability, reliability, scalability, or flexibility, we will choose the microservice architecture, otherwise, the monolithic architecture is a better choice.

In reality we often have a fixture of both. We can apply the microservice architecture to components that need availability, reliability, scalability, or flexibility, while grouping others into a monolithic component.

See also

←Previous Next→