Volume 9 · Chapter 3 — Enterprise Application Architecture & System Design
Microservices Architecture
3.1 Introduction
Microservices decompose a system into independently deployable services aligned with business capabilities. The architecture’s promise is organizational and operational scale - many teams shipping and scaling independently - but it delivers that only if boundaries, data ownership, and communication are designed well. Poorly done, it produces a distributed monolith: all the operational cost of distribution with none of the independence. This chapter focuses on the decisions that determine which outcome you get.
3.2 The Real Driver: Team and Scaling Independence
Microservices are justified primarily by independence - teams that can develop, deploy, and scale their piece without coordinating with everyone else - not by technology fashion. If a system is small, or one team owns everything, a modular monolith usually delivers the same design benefits with far less operational overhead. The question to ask before decomposing is: what independence do we actually need, and is the distributed-systems tax worth it?
3.3 Service Boundaries Follow Business Capabilities
The defining decision is where to cut. Boundaries follow bounded contexts and business capabilities so that each service is cohesive, owns its data, and changes for one business reason. Cutting by technical layer or shared entity produces services that must always deploy together and chatter constantly - the classic failure.
flowchart TB GW["API Gateway / BFF"] --> Cust["Customer Service\n(own DB)"] GW --> Acct["Accounts Service\n(own DB)"] GW --> Pay["Payments Service\n(own DB)"] Pay -- "events" --> Notif["Notification Service\n(own DB)"] Acct -- "events" --> Notif
3.4 Database Per Service
Each service owns its data and no other service reads its tables directly. This is what makes independent deployment and scaling real, and it is the hardest discipline to hold, because sharing a database is the tempting shortcut that silently recreates the monolith’s coupling. The consequence - no cross-service ACID transactions - drives the need for sagas and eventual consistency.
3.5 Communication: Sync vs Async
Services communicate synchronously (REST/gRPC) when a caller needs an immediate answer, and asynchronously (events/messages) when they should be decoupled in time. Overusing synchronous calls creates chains where one slow service degrades many - temporal coupling. Favoring events for state-change notifications keeps services independent and resilient.
3.6 The API Gateway and BFF
An API Gateway gives clients one entry point and centralizes cross-cutting concerns - routing, authentication, rate limiting, TLS. A Backend-for-Frontend goes further, tailoring an API per client type so a mobile app is not forced through a chatty, general-purpose interface. This keeps clients decoupled from the internal service topology.
3.7 Service Discovery, Deployment, and Observability
Because instances come and go, services find each other through discovery (DNS in Kubernetes, or a registry). They deploy independently via containerized CI/CD, and - critically - they are observable: centralized structured logs, distributed tracing, and metrics are not optional extras but the only way to understand a system whose behavior emerges from many interacting services.
When should you NOT use microservices?
When you do not need the independence they buy and cannot afford the complexity they cost. For a small system, a single team, an early-stage product whose boundaries are still shifting, or a domain without meaningful scaling or team-autonomy pressure, microservices add network latency, partial failure, eventual consistency, distributed transactions, and heavy operational tooling for little benefit. A well-structured modular monolith gives you the same clean boundaries and separation of concerns while keeping in-process calls, one datastore, and one deployment - far simpler to build and operate. I’d start modular and extract services only when a concrete pressure appears: a component needing independent scaling, or a team needing an independent release cadence. Adopting microservices by default, especially before the domain boundaries are understood, is a common and expensive mistake.
What is a distributed monolith and how do you avoid it?
A distributed monolith has the operational cost of microservices but the coupling of a monolith: services that share a database, must be released together, or call each other synchronously in long chains, so nothing can actually change or deploy independently. You avoid it by holding the disciplines that make services autonomous - database-per-service with no shared tables, boundaries drawn along business capabilities so services change for independent reasons, asynchronous event-based integration instead of chatty synchronous chains, and stable, versioned contracts so producers and consumers deploy on their own schedules. The litmus test is simple: if two services cannot be deployed independently, they are really one service split across two deployments, and you are paying distribution’s cost without its benefit.
Why is database-per-service so important, and what does it force you to change?
Database-per-service is the foundation of service independence: if each service owns its data and no one else reads its tables, services can change their schema, scale their storage, and deploy without coordinating - the whole point of the architecture. Sharing a database recreates hidden coupling, because a schema change in one service can break others, and it becomes the shortcut that quietly turns the system back into a monolith. The cost it forces is giving up cross-service ACID transactions: you can no longer wrap a multi-service operation in one database transaction. That drives the adoption of sagas (a sequence of local transactions with compensating actions) and eventual consistency, plus reliable eventing (the outbox pattern) and idempotent consumers. In short, owning data independently is what buys independence, and the price is designing for distributed consistency instead of relying on the database.
How do you decide service boundaries for a large enterprise platform?
I derive boundaries from the business, not the technology. Using domain analysis and Event Storming with domain experts, I identify bounded contexts and business capabilities - the areas that have their own language, their own data, and their own reasons and rate of change - and those become candidate service boundaries. I test each candidate against the properties a good service needs: can it own its data, be deployed independently, be owned by one team, and change for a single business reason without chatty coupling to others? Signals that a boundary is wrong include two services that always change or deploy together, long synchronous call chains between them, or a shared database. I also weigh team topology (Conway’s Law) so ownership aligns with boundaries, and I bias toward fewer, larger services early - even starting with a modular monolith - extracting a service only when a real pressure (independent scaling or release cadence) justifies it. The aim is high cohesion within services and loose, asynchronous coupling between them, aligned with both the domain and the organization.
A team wants to split a monolith into 30 microservices in one project. How do you guide them?
I’d slow the big-bang down, because splitting into many services at once - before the boundaries are proven and the operational capability exists - is how teams end up with a distributed monolith and an operations crisis. First I’d check the prerequisites: do they have the platform maturity (CI/CD per service, containers, centralized logging, tracing, service discovery, resilience patterns) to operate dozens of services? Rarely, at the start. Then I’d challenge the number - 30 services usually reflects splitting by entity or layer rather than by capability, which guarantees chatty coupling. I’d recommend a strangler-fig approach: first refactor the monolith into a modular monolith with clean, context-aligned internal boundaries and database schemas per module, which delivers most of the design benefit with none of the distribution cost and validates the boundaries cheaply. Then extract services one at a time, starting with the modules that have a real, demonstrated need for independent scaling or release, building the operational tooling as they go. This turns a risky rewrite into an incremental, evidence-driven evolution where each extraction is justified and the boundaries are proven before they are cemented across the network.
3.8 Banking Enterprise Scenario
A bank decomposes its platform into Customer, Accounts, Payments, and Notification services, each owning its database and owned by a dedicated team, fronted by a gateway with per-client BFFs. Payments and Accounts integrate through published events rather than synchronous chains, so a slow notification path never blocks a transfer, and cross-service workflows use sagas with compensation because no ACID transaction spans services. Every service ships through its own pipeline and emits traces, logs, and metrics to a central platform. Crucially, the team arrived here by first building a modular monolith and extracting Payments only when payday peaks demanded independent scaling - proving the boundary before distributing it.
Chapter Revision Notes
- Microservices buy team and scaling independence at the cost of distribution.
- Cut boundaries along business capabilities/bounded contexts, not layers.
- Database-per-service is essential - it forces sagas and eventual consistency.
- Favor async events over synchronous chains to avoid temporal coupling.
- Avoid the distributed monolith; start modular and extract on evidence.
- Observability (logs, traces, metrics) is mandatory, not optional.