What it is
A service boundary is the line that decides which logic and which data live in which service. Everything inside a boundary can change and deploy together; everything that crosses it becomes a network call or a message, with a contract that two teams have to agree on.
Where the lines go matters more than how many services there are. Good boundaries make most requests and most feature changes stay inside one service. Bad ones produce a distributed monolith: many deployables that still have to change, release and run together.
Why it exists
Splitting a system is only worth its cost (network calls, partial failures, distributed data) if the parts can then be changed, scaled and operated independently. That independence comes from the boundaries, not from the deployment unit. Two services that share tables, or that call each other several times for every request, keep all the coupling of a monolith and add the network on top.
How it works
Cut by business capability. A capability is something the business does: take orders, manage inventory, maintain the catalog, collect payments, ship parcels. Capabilities are relatively stable, have an obvious owner, and keep the rules and data that change together in one place. Domain-driven design gives a vocabulary for this: a bounded context is a part of the domain in which a model and its words have one meaning ("product" in Catalog has a description and images; in Inventory it is a SKU with a stock count). Bounded contexts are good boundary candidates.
Avoid entity and layer cuts. "One service per table" (Customer, Product, Price, Stock, Order) or "one service per layer" (UI, logic, data) spread every business operation across several services. A checkout then needs five synchronous calls, and every feature touches several teams.
Count the hops on the request path. Latency adds up along a synchronous chain, and so does failure. If a request needs n independent services, each available a fraction a of the time, the request can be available at most aⁿ: five services at 99.9% give about 99.5%, roughly five times the downtime of one. Chatty patterns (a call per item in a loop, back-and-forth between the same two services) multiply this further.
Give each service its own data. A service's tables are private. Others get its data in one of two ways:
- Ask the owner through its API, when they need the current value and can tolerate the dependency.
- Keep a copy fed by the owner's events (price changed, product renamed), when they need the data often and can accept that it is briefly behind. The copy is shaped for the reader's needs, not a mirror of the owner's schema.
Publishing events reliably usually needs the transactional outbox; multi-service business transactions need sagas rather than distributed locks.
Align with teams. Conway's law: systems end up shaped like the communication structure of the organisation that builds them. A boundary that one team owns end to end stays clean; a boundary that cuts through a team's daily work erodes.
When to use it
- When splitting a monolith, or deciding whether new functionality is a new service or part of an existing one.
- When a "microservices" system shows lockstep releases, chatty calls or a shared database: those are boundary problems.
- When designing data flows: decide which service owns each piece of data before deciding how others read it.
When not to
- Do not draw service boundaries before you understand the domain. Early on, boundaries move; inside a modular monolith moving them is a refactoring, across services it is a migration.
- Do not split purely for size or fashion. A capability that one team owns and that scales uniformly is fine as one service.
Trade-offs
| Choice | You gain | You pay |
|---|---|---|
| Capability boundaries | Requests and features mostly stay in one service | Harder to find; needs domain knowledge and team buy-in |
| Database per service | Independent schemas, isolated load | No cross-service joins or transactions; data copies and events |
| Local copy fed by events | No runtime dependency, fast reads | Eventual consistency; one more consumer to run and monitor |
| Synchronous API call for data | Always the current value | Latency and availability coupled to the owner |
| Fewer, larger services | Fewer hops and failure modes | Larger teams per service, coarser scaling |
Alternatives
- Modular monolith: the same boundaries as modules with enforced interfaces inside one deployable. Most of the design benefit, none of the network cost; split later where it pays off.
- Shared database, separate schemas per module: a stepping stone that enforces ownership by access rules while still running on one server.
- Merge services back: when two services always change together and talk constantly, merging them is a legitimate fix.
Failure modes
- Distributed monolith: services that must be released together because they share types, tables or tightly ordered calls.
- Chatty chains: one request fans into many sequential calls; latency and outage windows add up (aⁿ).
- Shared-database contention: one team's batch job or migration exhausts connections or locks for everyone.
- Integration through the database: a service reads another's tables "just for a report", and the owner can no longer change its schema.
- Entity services: a "Customer service" that every request needs becomes a bottleneck and a single point of failure.
- Stale copies treated as truth: a local copy used for decisions that need the current value (for example, final stock reservation) without checking with the owner.
In production
Teams find boundaries with event storming or capability mapping, then validate them against real traffic: trace a few key requests (distributed tracing shows the call graph) and count synchronous hops. Track which services change together in version control; frequent co-changes point at a misplaced line. Migrate a shared database gradually: give each table one owning service, route other readers through APIs or events, then move the tables. Record the price, address or other facts a service used at decision time with its own data (an order stores the price charged), so later changes in the owner do not rewrite history.
Common misconceptions
- "One service per entity is clean design." It mirrors the data model, not the business; every operation becomes a call chain.
- "Separate deployments mean independent services." Not if they share a database or must be released together.
- "Copying data between services is wrong." Deliberate, owned copies fed by events are the normal way to avoid runtime coupling; uncontrolled shared tables are the problem.
- "Smaller is better." Granularity should follow capabilities and teams. More services mean more hops, more failure modes and more coordination.
Interview angle
When you split a design into services, say why each line is where it is: name the capability, the owning team and the data it owns. Interviewers probe: how does Ordering get prices (API call versus event-fed copy, and the consistency trade-off), what happens to a checkout if Catalog is down, how many synchronous hops a key request makes, and how you would migrate off a shared database. Quoting aⁿ (five services at 99.9% ≈ 99.5%) shows you understand why hop count matters.
Model assumptions
The simulation is a simplified model, not a benchmark. Checkout does 5 ms of work, then calls each dependency one after another and holds a worker while it waits; entity services do 8 ms of work plus one database query (4 ms reads, 20 ms writes). Network hops take 3–4 ms between services and databases, and 20 ms between shoppers and Checkout. The shared database has 8 connections and a 200 ms pool timeout. The price import is a client that only writes. Service outages are scripted redeploys, not random. Ordering's local price copy is represented by the price updater consuming events; its effect on Ordering's data is not modelled. Arrivals are random (Poisson). Numbers show behaviour and orders of magnitude only.