Back to blog

Twelve engineers, one codebase: is it time to split the app?

Thắng Đoàn
Thắng Đoàn

FotoFlow is one codebase: accounts, photos, feed, notifications, billing, all deployed as one unit every Thursday. With 12 engineers across three teams, a bug in the feed now delays everyone's release, and last month a memory leak in reports crashed the whole process, uploads included. Microservices solve an organisational scaling problem. If you don't have that problem yet, they mostly add cost. The question is whether you have it yet.

What the monolith is still good at

Calls between features are plain function calls. One deploy ships everything. A stack trace shows the whole story. For a small team this is genuinely fast, and very large companies ran on monoliths for years. The pain that arrives with more teams is mostly about people: waiting on each other, and one team's bug becoming everyone's outage.

Split along business lines, then give each its data

Break the app into services along business capabilities: Users, Photos, Feed, Billing. Each is a separate program, owned by one team, deployed on its own schedule, behind an API gateway that gives clients one front door.

The boundary that matters is the database. If services still share one, a schema change by one team still breaks three others, so each service gets its own database and nobody else touches it. Need photo data in the Feed? Ask Photos through its API, or listen to its events. No more joins or transactions across services, which is exactly the next lesson's problem.

The bill arrives with the network

One feed page now takes several calls: gateway to Feed to Photos, plus Users. Each hop adds latency, and each can fail on its own. A function call never fails halfway. A network call does, partially, slowly, at the worst moment. Debugging spans four codebases, and you need everything from the reliability chapters just to stay where the monolith started.

The classic failure is the distributed monolith: one company split into twelve services that still read each other's tables and shipped together, so they paid the network costs and kept the coupling, and releases got slower. If services must be deployed together, they are one service. Boundaries first, split second.

Screens that combine data from many services hurt most: order history with product names was one SQL join once; now it is 20 calls to Catalog (the N+1 problem), and Catalog being down takes the page down. The standard fix is a local read copy: Feed keeps the few photo fields it displays and updates them from PhotoPublished events. One query again, and it keeps working when Photos is down.

What this does not solve

Independent deploys only work if teams cannot break each other by accident. Photos renames a field, its own tests pass, and every Feed call fails in production. Consumer-driven contract tests fix this: Feed publishes exactly which fields it relies on, and Photos' build runs those contracts before every release, so the change is blocked in CI instead of in production.

And how do you get there without a big-bang rewrite? The strangler fig: put the gateway in front of the monolith, build one new service, Billing, and route only billing paths to it. Everything else still goes to the monolith. Move one capability at a time; each step is shippable and reversible. Most teams should start with a modular monolith, one deployable with strict internal boundaries, and split out a module only when a team clearly needs independence.

Your last release waited on another team's bug. Which boundary would have set you free, and what would it cost in network hops?
Your services deploy together every time. Are they really services yet?

The app is splitting. Next in the series: Nine services and counting: who talks to whom?

Sources

Martin Fowler: Microservices

Martin Fowler: Monolith First

System Design Primer

Share:

Recommended for you

Enjoyed this article?

Subscribe for new articles. No spam. Unsubscribe anytime.

No pasting. This is the challenge.0/200

Typed live, never pasted.