Monolith or microservices: how to choose
What each one really costs, a simple way to decide, and why a modular monolith is the right start for most products.
Most teams ask this question too early and answer it for the wrong reason. Microservices are chosen because large companies use them, and monoliths are dismissed because the word sounds old. Neither is a reason. The honest answer depends on three things you can check today: how many people will work on the system, how different its parts are from each other, and how much operational work you can afford.
What the two words mean
A monolith is one application that is built, tested and released as a single unit. All of its parts run in one process and usually share one database. A call from one part to another is a normal function call.
A microservice system is many small applications, each released on its own and each owning its own data. A call from one to another crosses the network. That single difference is where every advantage and every cost comes from.
What a monolith gives you
- One thing to run. One build, one release, one set of logs, one place to look when something breaks.
- Changes that span features are easy. Renaming a field or moving a rule touches one codebase and ships in one release.
- Transactions are simple. Saving an order and reducing stock either both happen or neither does, because the database guarantees it.
- It is fast by default. A function call costs nothing compared with a network call.
The usual complaint about monoliths is not really about monoliths. It is about code with no internal boundaries, where every part reaches into every other part. That problem follows a team into microservices, where it becomes harder to fix because the tangle now runs over the network.
What microservices give you
- Teams can release without waiting for each other. This is the main benefit, and it only matters once several teams are queuing behind one release.
- Parts can scale separately. If image processing needs twenty machines and the rest needs two, you pay for exactly that.
- A fault can be contained. A crash in the recommendation service need not take checkout down, provided the callers were written to cope.
- Parts can use different tools where there is a real reason, such as a Python service for a model inside a Java system.
What microservices cost
Every call between services can now be slow, fail, or succeed twice. Code that was three lines becomes a retry policy, a timeout and a decision about what to show the user when the other side does not answer.
Data that used to be consistent now is not. With each service owning its own database, there is no single transaction across them. You design for eventual consistency: the order is saved, a message is published, stock is reduced a moment later, and something has to handle the case where that last step fails.
You also take on a platform: service discovery, centralised logging, tracing a request across services, a deployment pipeline for each one, and local development that can start enough of the system to be useful. A small team can spend more time on this than on the product.
A simple way to decide
- Fewer than about fifteen engineers on the system: start with a monolith. Coordination is not yet your bottleneck.
- The domain is still changing: start with a monolith. You do not yet know where the boundaries are, and a wrong boundary between services is expensive to move.
- One part has a very different load or risk profile: split that one part out and leave the rest together.
- Several teams are regularly blocked by a shared release: that is the signal microservices were designed for.
The middle path: a modular monolith
For most products the best starting point is a monolith with strict internal boundaries. Each module owns its tables, exposes a small public interface, and is not allowed to read another module’s data directly. It is still one deployment and one database server, so it stays cheap to run.
The value is that the boundaries are tested while they are still cheap to change. If a module later needs to become its own service, the interface already exists and the data is already separate. The move becomes a matter of putting a network call where a function call was.
If you do split, split in this order
- Pick the module with the clearest boundary and the least shared data, not the most important one.
- Put its interface behind an API inside the monolith first, and make every caller use it.
- Move its data to its own schema, then its own database.
- Only then deploy it separately, with monitoring and a fallback in the callers.
- Run both for a while before removing the old path.
The short version
Microservices solve an organisational problem at a technical cost. If you do not have the organisational problem yet, you are only paying the cost. Build one well-structured application, keep its modules honest, and split when a specific part gives you a specific reason.