Open the editor

Microservices architecture

Small services that each own one capability and its data, deployed independently.

Microservices architecture diagram: API gateway, Services, Database per service, Event broker

A microservices architecture builds an application as a set of small services, each responsible for one business capability, owning its own data and deployed on its own. Services talk over the network, through synchronous APIs or asynchronous events, and never share a database.

The main benefit is organisational: teams can change, deploy and scale their service without coordinating a release with everyone else. The price is a distributed system, with network failures, eventual consistency, more infrastructure and harder debugging.

The parts of the pattern

API gateway
One entry point for clients. It routes requests to services and handles cross-cutting concerns such as authentication.
Services
Orders, payments and shipping, each with its own codebase, pipeline and team.
Database per service
Each service owns its data. Others get it through the service's API or its events.
Event broker
Carries events such as OrderPlaced so services react without calling each other directly.

How it works

  1. A client calls the gateway, which routes the request to the orders service.
  2. The orders service writes to its own database and publishes OrderPlaced.
  3. The shipping service consumes the event and schedules a delivery in its own database.
  4. Each service is deployed and scaled separately, often on Kubernetes.

When to use it, and when not to

Good fit

  • Several teams need to ship independently on one product.
  • Parts of the system have very different load, availability or technology needs.
  • You have the platform basics: automated deployment, monitoring, tracing and on-call.

Think twice

  • A small team or a new product: start with a monolith or modular monolith.
  • Services that must change together for every feature (a distributed monolith).
  • No investment in observability: debugging across services without tracing is painful.

Edit this diagram

Click Open the diagram in the editor to get your own copy, saved in your browser. Rename the boxes to match your system, swap the generic boxes for technology icons from the palette, then export a PNG, SVG or PDF, or share a link. No sign-up.