Microservices Architecture

Splitting systems into independently deployable services, and knowing when not to.

Microservices structure a system as a set of small services, each owning a business capability, running independently and communicating through APIs or events. Done well, they let teams build, deploy and scale their parts without waiting for each other.

They also bring real costs: distributed systems are harder to test, debug and operate. Many teams would be better served by a well-structured modular monolith, at least to start.

Core principles

Modelled around business domains
Service boundaries follow business capabilities, often found through domain-driven design.
Independent deployment
Each service can be released without coordinating with others.
Own your data
Each service owns its data store; others access it only through its API or events.
Automation culture
CI/CD, infrastructure as code and observability are prerequisites, not extras.
Hide implementation details
Stable interfaces, often behind an API gateway, let internals change freely.

Communication

Services talk synchronously (REST, gRPC) or asynchronously (events, queues). Synchronous calls are simple but create runtime coupling: if one service is slow, its callers are too. Asynchronous events decouple services but make flows harder to follow. Use timeouts, retries with backoff and circuit breakers for every remote call.

The cost of distribution

Every network call can fail or be slow. Data consistency across services needs patterns such as sagas and the outbox pattern. Debugging requires distributed tracing. Each service needs its own pipeline, monitoring and on-call ownership. These costs are worth paying only when the benefits of independence are real.

Modular monolith first

A modular monolith keeps one deployable unit but enforces clear internal module boundaries. It gives much of the design clarity of microservices with far less operational overhead, and modules can be extracted into services later when there is a clear reason, such as different scaling needs or a separate team.

Teams and boundaries

Conway's Law applies strongly here: service boundaries tend to mirror team boundaries. Align each service with one owning team, keep teams small, and avoid services that several teams must change together, which is a sign the boundary is in the wrong place.

Migrating from a monolith

The strangler fig pattern is the safest route: put a routing layer in front of the monolith, build new capabilities as services, and move existing features out one at a time, starting with those that change most often or need different scaling.

Move data carefully. Split the database only after the service boundary is proven, and keep the old and new paths running side by side until you are confident.

Observability is not optional

In a distributed system, a single user request can pass through many services. Distributed tracing, correlated logs and consistent metrics are what make it possible to find where time is lost or where an error started. Build them in from the first service, using OpenTelemetry so the instrumentation isn't tied to one vendor.

How to put it into practice

  1. Start with a modular monolith unless you have clear reasons not to.
  2. Map business domains and draw service boundaries around them.
  3. Give each service one owning team and its own data store.
  4. Put CI/CD, tracing and centralised logging in place before splitting services out.
  5. Extract services gradually using the strangler fig pattern.
  6. Review boundaries when changes regularly span several services.

Common mistakes

  • Splitting into too many tiny services too early.
  • Shared databases between services, which recreate the monolith's coupling.
  • Chains of synchronous calls that make the whole system as fragile as its weakest link.
  • Adopting microservices without the automation and observability they need.

How to measure progress

  • Share of changes deployable by one team without coordination.
  • Deployment frequency per service.
  • Cross-service incidents and their recovery time.
  • Changes that required updating several services together.

Go further