Microservices

Build a system as small, independently deployable services, each owning one business capability and its own data, run by one team.

Description

Each microservice does one business job (orders, payments, search), owns its own database, and talks to others only through APIs or events. A team can change, deploy and scale its service without coordinating a release with anyone else.

The benefit is organisational speed at scale: many teams shipping independently. The cost is a distributed system: network calls that fail, data spread across databases with no shared transactions, and much more to deploy, monitor and secure. Microservices solve a team-scaling problem; for a small team they mostly add problems.

System design

one entry point1/orders2OrderPlaced3charge4reindex5ClientsAPI gatewayOrders serviceteam APayments serviceteam BSearch serviceteam CEvent bus

Microservices system design diagram

  1. Clients (client).
  2. API gateway (gateway).
  3. Orders service (service): team A.
  4. Payments service (service): team B.
  5. Search service (service): team C.
  6. Event bus (topic).
  7. Step 1: Clients → API gateway: one entry point.
  8. Step 2: API gateway → Orders service: /orders.
  9. Step 3: Orders service → Event bus: OrderPlaced.
  10. Step 4: Event bus → Payments service: charge.
  11. Step 5: Event bus → Search service: reindex.
  1. Clients reach the system through one gateway.
  2. Requests are routed to the service that owns the capability; each service has its own database.
  3. Services announce changes as events instead of calling each other directly…
  4. …so payments can react without the orders service knowing about it…
  5. …and search updates its index on its own schedule. Each team deploys its service independently.
AWS
ECS/EKS or Lambda per service; API Gateway; EventBridge or SNS/SQS; X-Ray for tracing.
Azure
AKS or Container Apps; API Management; Service Bus or Event Grid; Application Insights.
Google Cloud
GKE or Cloud Run; API Gateway; Pub/Sub; Cloud Trace.

When to use it

Use it when

  • Several teams need to deploy independently and are slowing each other down in one codebase.
  • Parts of the system have very different scaling, reliability or technology needs.
  • You have mature DevOps: automated deployment, observability, on-call, platform tooling.

Avoid it when

  • A small team or an early product. Start with a modular monolith; extract services when a boundary proves itself.
  • Business boundaries are still unclear. Wrong service boundaries are very expensive to move.
  • You can't invest in the platform: CI/CD, tracing, service discovery, secrets.

Pitfalls

  • The distributed monolith: services that must be deployed together or share a database. All the costs, none of the benefits.
  • Chatty synchronous calls chaining through many services, where latency and failures add up. Prefer events and coarse-grained APIs.
  • Services that are too small (nanoservices), more network than logic.
  • Missing observability. Without distributed tracing, debugging becomes guesswork.

Alternatives

Modular Monolith

Choose it when you want clear boundaries without distributed-systems costs. The usual first step.

Event-Driven Architecture

Choose it when the main need is loose coupling between parts through events; it pairs well with services.

A few larger services

Choose it when one service per team, rather than per entity, keeps independence while limiting the number of moving parts.