Architecture
Modular Monolith vs Microservices: Choosing for the Stage of Your Product
Microservices solve real problems, but they are problems of scale and organisation that many products do not have yet. Here is how to choose an architecture that fits where your product is today.
Kodvexa Engineering · · 7 min read
Few architecture questions generate as much debate as whether to build a monolith or microservices. The discussion is often framed as old versus modern, which is unhelpful. Both are legitimate approaches with different costs, and the right choice depends far more on the stage of the product and the shape of the team than on technical fashion.
This article explains what each option really involves, the signals that suggest one over the other, and how to keep your options open so that the decision does not need to be permanent.
What we mean by each term
A traditional monolith is a single deployable application. The problem with many monoliths is not that they deploy as one unit, but that their internal structure has eroded, so any part of the code can call or change any other part. Over time this makes changes risky and slow.
A modular monolith is still deployed as one unit, but its internals are organised into modules with clear boundaries. Each module owns its data and exposes a deliberate interface to the rest of the application. Other modules cannot reach into its tables or internal classes.
Microservices split the system into separately deployed services, each owning its own data and communicating over the network through APIs or messages. Each service can be built, deployed and scaled independently, usually by a team that owns it end to end.
The real costs of microservices
Microservices move complexity out of the code and into the infrastructure and the interactions between services. That trade is worthwhile in some situations, but the costs are significant and are often underestimated at the start.
- Every call between services can fail, time out or arrive twice, so retries, idempotency and fallbacks are required everywhere
- Transactions that span services need patterns such as sagas or outbox messaging instead of a simple database transaction
- Queries that join data across services become API calls or require replicated read models
- Each service needs its own pipeline, monitoring, alerting and on-call ownership
- Distributed tracing becomes essential just to understand what happened during a single request
- Changing a contract between services requires versioning and coordination between teams
For a small team, these costs compete directly with product work. A team of five maintaining a dozen services can spend more time on plumbing than on features.
What microservices are good for
The strongest reason for microservices is organisational. When many teams work on one codebase, they get in each other's way: merges conflict, releases need coordinating and a defect in one area blocks everyone. Splitting along team boundaries lets each team release on its own schedule.
There are technical reasons too. A component with very different scaling needs, such as a media processing pipeline, can be scaled separately. A component with stricter security or compliance requirements can be isolated. A part of the system that genuinely needs a different language or runtime can be built in it without affecting the rest.
Signals to help you choose
A modular monolith usually fits when
- The product is still finding its fit and the domain model is changing frequently
- The engineering team is small enough to coordinate informally, typically one or two teams
- Load is moderate and can be handled by scaling the whole application horizontally
- You do not yet have mature automation for deployment, monitoring and incident response
Microservices start to make sense when
- Several teams need to release independently and coordination has become a bottleneck
- Domain boundaries have been stable for some time and are well understood
- Specific components have scaling, availability or compliance needs that differ sharply from the rest
- The organisation can support the operational platform that many services require
Building a modular monolith that stays modular
A modular monolith only works if the boundaries are enforced. Good intentions erode under deadline pressure, so the structure needs support from tooling and conventions.
- Organise code by business capability, such as billing, scheduling or catalogue, rather than by technical layer
- Give each module its own database schema or table prefix, and forbid other modules from querying it directly
- Expose a small public interface from each module and keep everything else internal
- Use in-process events for cross-module reactions so that modules do not call each other synchronously for everything
- Add architecture tests to the build that fail when a module references another module's internals
In .NET, for example, internal visibility and separate projects per module make illegal references a compile error. Libraries such as ArchUnitNET for .NET or ArchUnit for Java let you express rules like "the scheduling module must not depend on billing internals" as tests. In TypeScript monorepos, lint rules can enforce import boundaries between packages.
[Fact]
public void Scheduling_does_not_depend_on_billing_internals()
{
var rule = Types().That().ResideInNamespace("App.Scheduling")
.Should().NotDependOnAny(Types().That().ResideInNamespace("App.Billing.Internal"));
rule.Check(Architecture);
}Extracting a service when the time comes
If a module later needs to become a separate service, a well-bounded module is much easier to extract. Its public interface becomes the service API, its in-process events become messages on a broker, and its schema moves to its own database. Because other modules already avoid its internals, the blast radius of the change is limited.
Extract one service at a time, starting with the module that has the clearest reason to be separate. Run the new service alongside the old code path until you are confident, then retire the in-process version. Resist the temptation to split everything once the first extraction succeeds; each service should justify its operational cost.
Avoiding the distributed monolith
The worst outcome is a set of services that must be deployed together, share a database and call each other synchronously in long chains. This combines the coupling of a monolith with the operational overhead of microservices. If you find that a change routinely requires coordinated releases of several services, the boundaries are probably in the wrong place, and merging some services back together is a legitimate fix.
Choosing for today, preparing for tomorrow
For most new products and many established ones, a well-structured modular monolith is the pragmatic starting point. It keeps delivery fast and operations simple while the domain settles, and it preserves a clear path to services if growth demands them. Microservices are a response to specific scaling and organisational pressures; adopt them when you can name those pressures, not in anticipation of problems you may never have.