Microservices
Microservices are an architectural style in which an application consists of small, independent services that each implement one business capability, own their data, and are delivered independently.
Microservices are an architectural style: an application consists of many small, independent services. Each implements one business capability within a bounded business area, owns its data, and can be delivered and scaled independently.
What makes the style
The Azure architecture documentation names the core: every service is self-contained and implements a single business capability within a bounded context, a natural boundary in the business area within which one domain model applies. Services talk to each other through well-defined interfaces (APIs) or through messages. Usually, an API gateway as the entrance, a message broker such as Azure Service Bus, observability with distributed tracing, and a platform for operation, such as Azure Container Apps or Kubernetes, belong to it.
This brings advantages: services are delivered one by one, scale one by one, fail one by one, and small teams can own them from start to finish. But the documentation names the costs just as clearly:
- Complexity: more moving parts, plus service discovery, consistency, and transactions across service boundaries.
- Data consistency: every service stores its data itself. A change across several services is no longer a single ACID transaction; you work with eventual consistency.
- Network and latency: chains of calls between services cost time.
- Operation: it takes a mature DevOps culture, correlated logging, and automatic delivery (DevOps).
The anti-patterns it names include services built without an understanding of the business domain, a shared database schema, and shared libraries between services that couple them tightly.
Microservices for .NET developers
In .NET, a service is usually a small ASP.NET Core application in a container. Azure Container Apps offers managed orchestration and scaling. REST, gRPC, and messages are available for communication, and a gateway for the entrance. The most important question comes before the technology: where are the business boundaries?
An example from the Kladde
In the course, the Kladde, the sample application of a small IT office, is a modular monolith: one program with clearly separated modules that know each other only through contracts. For every module, it is written down what would have to happen for a service of its own to pay off, such as independent teams or very different scaling. Only then does the first candidate move into a service of its own.
How it differs
- Microservices and the monolith: A monolith is delivered as one unit. A modular monolith has the same inner order without a network between the parts.
- Microservices and serverless: Serverless describes how a service is run, microservices how the application is cut.
- Distributed monolith: Services that can only be changed and delivered together have the costs of both worlds.
In the course
You learn this in K4, module 4.11, in the lesson Modular monolith versus microservices, and in module 4.12 in An API gateway with YARP and Microservices or virtual actors?.
Further reading on the blog
Sources
- Microsoft Learn, Microservices architecture style: https://learn.microsoft.com/azure/architecture/guide/architecture-styles/microservices