Video in progress

When do you pick a modular monolith instead of microservices?

If the team is small (one or two teams), the domain is still changing, or the platform isn't mature (no CI/CD, observability, on-call): a modular monolith. Microservices solve an organizational scaling problem, not a technical one.

📖 Answer

The main benefit of microservices is that many teams can deploy independently without waiting on each other, and that parts can be scaled separately. The cost is big: network errors, eventual consistency, distributed tracing, a pipeline per service, on-call, versioning.

I choose a modular monolith if:

  • there are fewer than 15–20 engineers, in one or two teams;
  • the product is still searching for product–market fit and the domain boundaries change every month (moving a wrong boundary inside a monolith is cheap, between services it is very expensive);
  • Kubernetes, centralized logging, tracing and alerting are missing or weak;
  • the load fits on one or two instances.

A modular monolith doesn't mean a "big ball of mud". In it:

com.shop.order      -> exposes only the order.api package
com.shop.payment    -> its own tables, no JOIN into another module's tables
com.shop.catalog

Modules call each other only through a public interface or internal events (Spring ApplicationEvent, Spring Modulith). ArchUnit or Spring Modulith's verify test stops a PR that breaks a boundary in CI.

Then if you later need to extract one module into a service, the work is mostly swapping the transport layer.

In an interview it's also useful to say that some parts make sense as separate anyway, for example heavy video encoding or batch jobs with a different resource profile. It isn't an "all or nothing" choice.