Volume 4 · Chapter 1 — .NET Distributed Systems and Microservices Architecture

Microservices Fundamentals

Goutham Mayaluri 6 min read .NETC#Microservices

1.1 Introduction

Microservices architecture structures an application as a collection of small, independently deployable services, each owning a business capability and its data. Enterprises adopt it for independent scaling, team autonomy, deployment flexibility, and fault isolation. But microservices are not free: they trade the simplicity of a monolith for real distributed-systems complexity, so the defining skill is knowing when they are justified and how to avoid the common failure mode - the distributed monolith. (Volumes 6, 9, and 12 develop these patterns in architectural depth.)

1.2 Monolith vs Microservices

A monolith is one deployment unit - simple to build, test, and deploy initially, but its components become tightly coupled and it must be scaled and released as a whole. Microservices are many independent units - more complex to operate, but each can be developed, deployed, and scaled independently by an autonomous team. The trade is initial simplicity for long-term independence, which only pays off when you actually need that independence.

flowchart TB
  Client["Client applications"] --> GW["API Gateway"]
  GW --> Cust["Customer Service"]
  GW --> Pay["Payment Service"]
  GW --> Tx["Transaction Service"]
  Cust --> CDB[("Customer DB")]
  Pay --> PDB[("Payment DB")]
  Tx --> TDB[("Transaction DB")]

1.3 Characteristics and Trade-offs

A microservice owns a single business capability and its data, deploys independently, scales independently, exposes clear API/event contracts, and is owned by an autonomous team. The costs are distributed complexity, network failures, data-consistency challenges (no cross-service ACID), and heavy operational overhead (per-service CI/CD, monitoring, service discovery). These costs are the price of the independence, so you pay them only when the independence is worth it.

1.4 Communication Styles

Services communicate synchronously (HTTP/gRPC) when a caller needs an immediate response, and asynchronously (events via a message broker) when they should be decoupled in time. Overusing synchronous chains recreates coupling; favoring events for state-change notifications keeps services independent and resilient - the subject of later chapters.

Senior Interview Question

When should you choose microservices, and when should you not?

Microservices are appropriate when you genuinely need the independence they provide and can afford their complexity - specifically when a system requires independent scaling of different parts (a component with a very different load profile), multiple autonomous teams that need to develop and deploy without coordinating, independent deployment and release cadences, clear business boundaries that map to separate capabilities, and where fault isolation between capabilities is valuable. In those situations the distribution cost buys real benefits: teams move in parallel, each service scales and releases on its own schedule, and a failure in one capability doesn’t take down others. They should NOT be chosen simply because they’re popular, nor for small systems, single teams, early-stage products whose boundaries are still shifting, or domains without meaningful scaling or team-autonomy pressure - because there the architecture adds network latency, partial failure, eventual consistency, distributed transactions, and heavy operational tooling for little benefit, and a well-structured modular monolith would deliver the same clean boundaries with far less complexity. The mature approach is to start with a modular monolith and extract services only when a concrete pressure appears - a component needing independent scaling, or a team needing an independent release cadence - rather than adopting microservices by default before the boundaries are even understood. So the decision hinges on whether you actually need independent scaling, team autonomy, and deployment, and whether you have the operational maturity to run many services; if yes, microservices pay off, and if not, they impose their considerable cost for no return, which is why choosing them for fashion rather than need is a classic, expensive mistake.

Principal Engineer Question

What is the biggest mistake teams make with microservices, and how do you avoid it?

The biggest mistake is building a distributed monolith - services that are technically separate but remain tightly coupled, so you pay the full operational cost of distribution (network calls, partial failure, per-service deployment and monitoring) while getting none of the independence that justifies it. It happens when services share a database, must be deployed together, or call each other in long synchronous chains, so nothing can actually change or deploy independently. Related mistakes are decomposing too early (before the domain boundaries are understood, cementing wrong boundaries), splitting by technical layer or entity rather than business capability (producing chatty, coupled services), and creating too many tiny services that generate more coordination and operational cost than value. To avoid it, I hold the disciplines that make services genuinely autonomous: each service owns its own database and no other service reads its tables directly (database-per-service is the foundation of independence); boundaries follow business capabilities / bounded contexts so services change for independent reasons; integration is asynchronous via events where possible rather than chatty synchronous chains, with stable, versioned contracts so producers and consumers deploy on their own schedules. I also start with a modular monolith with clean internal boundaries and extract a service only when a real, demonstrated pressure justifies the distribution - proving the boundary before distributing it - and I invest in the operational platform (CI/CD per service, observability, resilience) before proliferating services. The litmus test I apply constantly is: can these two services be deployed independently? If not, they’re one service split across two deployments - a distributed monolith - and I’ve made the architecture worse, not better. Avoiding that outcome is largely about database-per- service, capability-aligned boundaries, asynchronous integration, and extracting on evidence rather than enthusiasm.

1.5 Banking Enterprise Scenario

A banking platform starts as a monolith containing customer, payment, account, and reporting functionality. As teams and transaction volumes grow, it evolves into business-aligned services - Customer, Account, Payment, Transaction, Notification - each owning its data and deploying independently, integrating through events with centralized security and monitoring. Crucially, the team extracts services along proven business boundaries (not by mirroring tables) and only where independent scaling or team autonomy justifies it - avoiding a distributed monolith.

Chapter Revision Notes

  • Microservices are organized around business capabilities, each owning its data.
  • They trade a monolith’s simplicity for independence - pay the cost only when you need it.
  • Boundaries matter more than size; the failure mode is the distributed monolith.
  • Use sync (HTTP/gRPC) for immediate responses, async (events) for decoupling.
  • Start modular; extract services on evidence of a real scaling or autonomy need.