Volume 4 · Chapter 2 — .NET Distributed Systems and Microservices Architecture
Service Boundary Design
2.1 Introduction
Defining service boundaries is the single most important - and most difficult - decision in microservices. Good boundaries enable independent development, deployment, and scaling; poor ones create a distributed monolith. The guiding principle is that services should represent business capabilities, not technical components like database tables or application layers, and should have high cohesion internally and low coupling to each other.
2.2 Business Capabilities, Cohesion, and Coupling
A service boundary is a candidate when a business capability has clear ownership, responsibilities, and lifecycle - Customer Management, Payments, Account Management, Notifications. Within a service, functionality that naturally belongs together should be together (high cohesion); between services, communication should go through stable contracts with no knowledge of each other’s internals (low coupling).
2.3 The Shared-Database Anti-Pattern
Sharing one database across services is the classic mistake that recreates coupling: a schema change affects multiple teams, independent deployment becomes impossible, and ownership blurs. Database-per-service is what makes services genuinely independent - the strongest boundary.
flowchart TB
subgraph Bad["Anti-pattern: shared database"]
C1["Customer Service"] --> SDB[("Shared DB")]
P1["Payment Service"] --> SDB
end
subgraph Good["Correct: database per service"]
C2["Customer Service"] --> CDB[("Customer DB")]
P2["Payment Service"] --> PDB[("Payment DB")]
C2 -. "events / API" .- P2
end 2.4 Conway’s Law and Boundary Identification
Conway’s Law observes that system architecture tends to mirror the organization’s communication structure - so teams organized around business capabilities produce better service boundaries than teams organized by technical layer. Techniques for finding boundaries: analyze business workflows, identify ownership and independent change patterns, separate different scalability needs, and notice where the same word means different things (a signal of separate bounded contexts).
How do you decide whether a piece of functionality should become its own microservice?
I evaluate it against the properties that justify the cost of a separate service, rather than splitting reflexively - not every module should be a service. The questions I ask: Does it represent a distinct business capability with clear ownership, so it can change for its own business reasons independent of others? Can it own its data cleanly, without needing to share tables with other services (database-per- service being the foundation of independence)? Does it have an independent lifecycle - a different release cadence or the need to deploy without coordinating with the rest? Does it have a genuinely different scalability profile that benefits from scaling on its own? Is there a separate team that would own it (Conway’s Law - aligning services with teams)? And crucially, is the coupling to other capabilities low enough that it won’t just become a chatty, dependent fragment - i.e. can it interact through stable contracts and events rather than constant synchronous calls? If a capability scores well on these - distinct business ownership, own data, independent lifecycle and scaling, an owning team, and loose coupling - it’s a good candidate to extract. If instead it’s tightly bound to another capability’s data and workflow, changes and deploys in lockstep with it, has no independent scaling need, or is so small that operating it as a service costs more than it’s worth, it should remain part of a larger service or module. I also weigh operational readiness - each new service adds CI/CD, monitoring, and failure-handling overhead. So the decision is driven by business ownership, data ownership, independent lifecycle and scaling needs, team structure, and coupling, with a strong bias against over-splitting: I extract a service when the independence it provides is genuinely needed and the capability can stand alone with its own data and contracts, not simply because it’s a separable piece of code.
What makes a good microservice boundary, and how do you fix a system that split into services sharing the same database?
A good boundary has clear business ownership (it maps to a business capability and an owning team), high cohesion (the things inside change together for the same reasons), low coupling (it interacts with others only through stable contracts, not shared internals), its own data (no shared database), and the ability to be deployed and scaled independently. In short, it’s a cohesive business capability that owns its data and can evolve on its own - which is exactly what the problem system lacks: services that were split apart but all depend on the same database tables are a distributed monolith, coupled through the shared schema, so a schema change ripples across teams, they can’t deploy independently, and ownership is unclear - they’ve taken on distribution’s operational cost without gaining independence. To fix it, the core move is to give each service ownership of its own data, decoupling them at the database level. I’d redraw the boundaries around business capabilities using domain analysis (bounded contexts) so each service owns a coherent slice of the domain and its data, then carefully separate the shared database: identify which data belongs to which capability, split the schema so each service has its own database (or at minimum its own schema with no cross-service foreign keys or queries), and eliminate direct cross-service table access. Where a service needs another’s data, it either calls the owner’s API (for immediate needs) or subscribes to the owner’s events and maintains its own local copy (accepting eventual consistency) - communication through contracts and events, not shared tables. I’d do this incrementally and safely (often via the strangler approach and expand-and-contract on the data), using change data capture or events to migrate and keep data consistent during the transition, and I’d establish clear service ownership so each team owns its capability’s code and data. The result is services with genuine boundaries - business-aligned, cohesive, loosely coupled, and data-owning - that can finally be developed, deployed, and scaled independently, which is the whole point. The overarching lesson is that a good boundary is defined by business ownership plus data ownership plus independence, and the shared-database anti-pattern is precisely what destroys those, so fixing it means restoring per-service data ownership and contract-based communication.
2.5 Production Scenario
A bank splits its monolith into services, but they all depend on the same database tables - a distributed monolith where schema changes affect every team and nothing deploys independently. The architecture team redraws boundaries around business capabilities (Customer, Account, Payment, Transaction, Notification), gives each service its own database, establishes clear ownership, and replaces shared-table access with APIs and events - restoring genuine service independence.
Chapter Revision Notes
- Align services with business capabilities, not technical layers or tables.
- Aim for high internal cohesion and low coupling through stable contracts.
- Database-per-service is essential; the shared-database anti-pattern recreates coupling.
- Conway’s Law: capability-aligned teams produce better boundaries.
- Not every module should be a service - extract when independence is genuinely needed.