Monolith vs microservices
When splitting a system into services pays off, what it costs, and how to migrate without a rewrite.
16 min readThe monolith is a valid architecture
A well-structured monolith is one deployable with clear internal modules. Calls between modules are function calls measured in nanoseconds, transactions span the whole domain, and there is one thing to deploy, monitor and debug. Shopify and Stack Overflow have run very large businesses on modular monoliths. The monolith scales horizontally behind a load balancer just like any stateless service. Its real limits are organisational: past roughly 50 to 100 engineers, everyone shares one release train, one build, and one blast radius.
What microservices buy you
Splitting into services lets teams deploy independently, scale hot paths separately (the search service needs 40 instances, the admin service needs 2), choose fitting storage per service, and isolate failures. Those benefits are real only if each service owns its data. A set of services sharing one database is a distributed monolith: you pay all the network costs and still cannot change a schema without coordinating every team. Other services get the data they need through the owner's API or by subscribing to its events and keeping a local, read-only copy.
What they cost
Every in-process call becomes a network call with a latency of around 0.5 to 2 ms inside a data centre, a failure mode, and a serialisation cost. A page that made 30 internal calls in a monolith now pays for 30 network hops unless you batch them or run them in parallel.
- Distributed transactions replace local ones (sagas, covered later)
- Debugging needs distributed tracing and correlation IDs
- Each service needs its own CI, deploys, alerts, on-call and capacity plan
- Data duplicated between services drifts and must be reconciled
Migrating with the strangler fig
Never rewrite from scratch. Put a gateway or proxy in front of the monolith, carve out one capability at a time behind a new service, and route that slice of traffic to it. Start with a capability that has clear data ownership and a high change rate, so the payoff is immediate. Shift traffic gradually, 1% then 10% then 100%, comparing error rates and latency at each step. Keep the old path working until the new one has carried full production traffic for a while, then delete it.
Key takeaways
- Start with a modular monolith; split when team size or divergent scaling needs force it
- Microservices that share a database are a distributed monolith with extra latency
- Every service boundary adds network latency, failure modes and operational cost
- Migrate incrementally with the strangler fig pattern, one capability at a time
Sign in to track lessons and earn badges.