What are microservices?

Microservices architecture is a cloud-native approach that decomposes applications into loosely coupled, independent services deployed in containers managed by orchestration platforms such as Kubernetes.

Each service operates independently with its own technology stack, including dedicated databases and data management models. Communication between services occurs via REST APIs, event streaming platforms such as Apache Kafka, and message brokers, while teams design services around business capabilities with clear boundaries called bounded contexts.

This modern approach to software development supports the operational flexibility required for modern digital transformation initiatives, such as DevOps automation and CI/CD pipelines, cloud migration, application modernization and artificial intelligence (AI) integration.

What are microservices design patterns?

Microservices design patterns are strategies for building software using a microservices architecture, which breaks down a single application into smaller components or services.

These architecture patterns provide standardized solutions for everyday challenges that development teams face when implementing distributed computing systems, including service communication, data consistency, fault tolerance and system scalability.

Types of microservices design patterns

Microservices design patterns fall across five key areas that provide tested solutions that help teams solve distributed architecture challenges:

  1. Service communication and discovery

  2. Data and transaction management

  3. Resilience and fault handling

  4. Architecture and integration

  5. Event and communication

1. Service communication and discovery

Service registry pattern

The service registry pattern creates a central directory where services register their endpoints and health status, eliminating the need for fixed addresses. When services need to communicate, they query the registry to find available server instances. For example, when a payment service needs to contact an inventory service, it checks the registry to locate healthy inventory instances.

API gateway pattern

An API gateway pattern creates a single entry point between clients and multiple back-end microservices. Instead of clients making separate calls to different services, the API gateway receives one request, routes it to the appropriate microservices and combines the responses into a single result.

For example, when loading a product page, the gateway can simultaneously fetch product details, pricing, inventory and reviews from different services. It then returns all of this information in a single, consolidated response to the client.

Service discovery pattern

A service discovery pattern solves the challenge of services locating each other in dynamic environments. As microservices scale up or are updated to a new version, their network locations constantly change. Service discovery patterns provide automated mechanisms for services to register themselves and find other services they need to communicate with, eliminating the need for hardcoded addresses.

2. Data and transaction management

Database per service pattern

The database per service pattern ensures that each microservice owns and manages its own database, eliminating shared data dependencies between services. This approach prevents direct data access between services and reduces coupling, though it requires services to communicate through APIs when they need information from other information sources. For example, in an enterprise resource planning (ERP) system, the accounting service manages financial data independently from the HR service's employee database.

Saga pattern

A saga pattern manages transactions that span multiple microservices by breaking them into coordinated steps. Each service completes its local transaction and triggers the next step in the chain. If any step fails, the pattern automatically runs actions to undo previous steps. For example, when processing an online order, if payment fails after inventory is reserved, the saga automatically releases the reserved items.

CQRS (command query responsibility segregation pattern)

The CQRS pattern separates data modification (commands) from data retrieval (queries) by using dedicated models for each. This division allows the system to optimize each path independently—minimizing write contention on the command side and reducing query latency on the read side. In an e-commerce system, placing an order uses the write-optimized command model, while generating a sales report leverages the read-optimized query model.

3. Resilience and fault handling

Circuit breaker pattern

The circuit breaker pattern prevents failures in one service from spreading throughout the entire system by monitoring calls to downstream services and stopping requests when failures are detected. When a service becomes unresponsive, the circuit breaker "trips" and blocks further calls, protecting system resources and preventing cascading failures.

For example, if an inventory service goes down, the circuit breaker stops the order service from making repeated failed requests. This allows the rest of the system to continue functioning while providing fallback responses to customers.

Bulkhead pattern

The bulkhead pattern isolates system resources to prevent failures in one area from affecting the entire system. Like compartments in a ship's hull, bulkheads separate different functions so that if one fails, the others remain operational. The pattern limits the number of concurrent requests or resources allocated to specific services.

4. Architecture and integration

Backend-for-frontend (BFF) pattern

A backend-for-frontend (BFF) pattern creates a dedicated backend service tailored to each specific front-end interface. Because mobile apps have different requirements than web applications (for example, smaller screens, limited bandwidth, varying performance capabilities), the BFF pattern lets developers optimize each backend for its particular front end.

Entity and aggregate pattern

An entity and aggregate pattern organizes related data into logical units based on domain-driven design (DDD) concepts. An entity represents a distinct object with a unique identity, like a customer account identified by an email address. An aggregate combines related entities that must be updated together as a single unit.

For instance, in an e-commerce system, an order aggregate would include the order details, line items and shipping information, all of which need to stay synchronized when changes occur.

Strangler pattern

A strangler pattern helps manage the process of refactoring a monolithic application into a more maintainable microservices architecture. New microservices are gradually built alongside the existing monolith, slowly taking over functionality until the old system is replaced completely. The name comes from the metaphor of how a vine (microservices) gradually grows around and eventually strangles a tree (the monolithic application) over time.

5. Event and communication

Event-driven pattern

An event-driven pattern enables microservices to communicate asynchronously by publishing and consuming events rather than making direct service calls. When a service completes an action, it broadcasts an event that other interested services can listen to and respond accordingly. This approach creates loose coupling between services, allowing them to operate independently while still coordinating their activities through a shared event system.

Sidecar pattern

A sidecar pattern refers to deploying a secondary container (the "sidecar") alongside a primary application or service within the same execution environment. This sidecar handles cross-cutting concerns (for example, logging, monitoring, security, observability), extending the functionality of the main application without modifying its codebase.

Adapter microservices pattern

An adapter microservices pattern enables communication between incompatible systems or interfaces. Just like a travel adapter lets you plug your device into foreign outlets, adapter patterns convert between different data formats, protocols or APIs. This pattern is beneficial when integrating with legacy systems or third-party services that use different communication standards.

Microservices design use cases

Microservices design patterns are particularly valuable in industries that require high scalability, complex business logic and reliable system performance. Top use cases include:

Benefits of microservices design patterns

Microservices design patterns offer best practices for managing today's complex distributed systems and offer these wide-ranging benefits: