Skip to content
Tutorials Center
My learning

Topics

Lesson 37 of 37 ยท Practice and Review

Microservices Cheat Sheet

A one-page microservices cheat sheet: which pattern solves which problem, resilience defaults to start from, delivery guarantees, deployment options and a production checklist.

This page is the quick reference you open when you already know the ideas and need to recall which pattern fits, what a sensible starting value is, or what to check before going live. Every row links to the lesson that explains it properly.

Nothing here is a law. The numbers are starting points that you should tune with real measurements, and the tables are deliberately short. Two tiny stand-ins at the end (a readiness scorer and a backoff table) show how to turn a checklist and a formula into something you can run in a review.

Think in four questions

Where is the boundary? Capability, data owner, team.
How do they talk? Ask now, or tell later.
What if it fails? Timeout, retry, breaker, fallback.
Can I see it? Logs, metrics, traces.
1 / 2

Which pattern for which problem

Problem Pattern Use when Lesson
Where to cut services Bounded contexts, business capabilities Always, before splitting Finding Boundaries with Domain-Driven Design
Migrate a live system Strangler fig, anti-corruption layer Replacing a legacy system piece by piece Decomposition Strategies
Two services need the same data Owner API, events, local copy Instead of sharing tables Database per Service and Data Ownership
Need an answer now Synchronous HTTP or gRPC Caller cannot proceed without it Synchronous Communication with HTTP APIs
Work can happen later, many listeners Queue or pub/sub, events Decoupling, bursts, fan-out Asynchronous Messaging and Events
One entry point for clients API gateway, BFF Routing, auth, aggregation API Gateway and Backend for Frontend
Find healthy instances Service discovery, load balancer Instances come and go Service Discovery and Load Balancing
Business transaction across services Saga (orchestrated or choreographed) No distributed transaction Sagas
Update data and publish an event Transactional outbox Avoid dual-write inconsistency The Transactional Outbox and Idempotent Consumers
Full history or independent read scaling Event sourcing, CQRS History or read models matter Event Sourcing and CQRS
Flaky dependency Timeout, bounded retry with backoff and jitter Idempotent calls to a recoverable service Timeouts, Retries and Exponential Backoff
Failing dependency drags you down Circuit breaker, bulkhead, fallback Fail fast, isolate, degrade gracefully Circuit Breakers, Bulkheads and Fallbacks
Overload Rate limit, load shedding, backpressure Protect capacity Rate Limiting, Load Shedding and Backpressure
Changing a contract safely Tolerant reader, expand and contract Consumers deploy on their own schedule API Versioning and Evolving Contracts

Resilience defaults to start from

These are conservative starting values for typical interactive web traffic. Measure your own latency and adjust.

Setting Starting point Notes
Connect timeout about 1 s Short; a connection that is not made quickly rarely will be
Request timeout 2 to 3 times the dependency's p99, often 1 to 5 s Always set one; never wait forever
Retry attempts 2 or 3 in total Only for idempotent operations and for timeouts or 5xx; never for 4xx
Backoff base 100 ms, doubling, cap 2 to 10 s, with jitter "Full jitter" picks a random wait between 0 and the current ceiling
Retry budget retries at most about 10 percent of traffic Stops retry storms during an outage
Circuit breaker open after about 50 percent failures in a window with a minimum number of calls (say 10), or 5 in a row Cool-down 10 to 30 s, then one trial call
Bulkhead a separate concurrency limit per dependency One slow service must not use every thread
Rate limit token bucket sized to real capacity; respond 429 with Retry-After Per client or per key
Health checks liveness (am I stuck?) and readiness (can I take traffic?) Do not put dependency checks in liveness
Graceful shutdown stop accepting, finish in-flight, exit within the grace period (often 30 s) Avoids dropped requests during deploys

Delivery and consistency at a glance

Term Meaning What you must do
At-most-once A message may be lost, never repeated Accept loss (metrics, telemetry)
At-least-once Never lost, may repeat Make consumers idempotent (the usual choice)
Exactly-once processing Effect happens once At-least-once plus idempotency or deduplication
Strong consistency A read sees the latest write Costs latency and availability during partitions
Eventual consistency Copies converge after a while Show users their own writes; design for stale reads
Quorum Read set and write set overlap when R + W > N Tune R and W for the trade-off

Deployment options

Strategy How Rollback Watch out for
Rolling Replace instances gradually Roll the other way Two versions run at once, so keep contracts compatible
Blue-green Full second environment, switch traffic Switch back Double capacity; database changes must work for both versions
Canary Small share of traffic to the new version, then more Set share to 0 Needs good metrics to judge
Feature flag Ship code off, enable by group Turn the flag off Remove stale flags

See Deployment Strategies and CI/CD and Configuration, Feature Flags and Secrets.

Production checklist

Before a service takes real traffic:

Ownership and design

  • One team owns it; there is a named on-call contact.
  • It owns its data; no other service reads its tables.
  • Its API or event contract is written down and versioned.

Reliability

  • Every outbound call has a timeout, and retries have a limit and jitter.
  • Handlers and write endpoints are idempotent.
  • Circuit breaker or fallback exists for each critical dependency.
  • Events are published through an outbox (or an equivalent safe mechanism).

Operations

  • Readiness and liveness endpoints; graceful shutdown works.
  • Structured logs with a correlation or trace id; dashboards for rate, errors, duration and saturation; alerts that point to user impact.
  • Automated build, tests (including contract tests) and a deploy with a tested rollback.
  • Configuration comes from the environment; secrets come from a secret store and can be rotated.

Security

  • The service authenticates callers and checks scopes; no "trusted network" assumption.
  • Input is validated at the edge; sensitive data is minimized and not logged.
  • Dependencies and images are scanned and kept up to date.

See Authentication and Authorization Between Services and Securing the Edge, Data and Secrets.

A readiness scorer

The first stand-in turns a checklist into a score. Real readiness reviews are conversations, but a script that lists the gaps keeps the discussion honest. The checks here are a made-up subset; replace them with your own.

JS Production readiness scorer

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The weights are opinions. The useful part is the sorted list of gaps: it turns "are we ready?" into "which three things do we do first?".

A backoff table

The second stand-in prints the retry schedule for the defaults above. With full jitter the actual wait is random between 0 and the ceiling, so the table shows the ceiling and the worst-case total, which is what you need to compare with your timeout budget.

JS Backoff ceilings and worst-case wait

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Remember that this is only the waiting between attempts. The calls themselves can each take up to the request timeout, so the worst case for the caller is roughly attempts x timeout + total waiting, and that has to fit inside the time the user will wait.

Defaults copied from a cheat sheet are guesses about someone else's system. Load-test, look at your dependency's real p99, and set values you can explain.

Check your understanding

Quick check ยท 3 questions

of 3 answered You scored / 3 ยท perfect!

  1. 1. A message broker may deliver the same message twice. What is the usual response?

    At-least-once delivery plus idempotent consumers is the standard way to get exactly-once effects.
  2. 2. Which problem is the transactional outbox designed to solve?

    The event row is saved in the same local transaction as the data, so a relay can publish it reliably afterwards.
  3. 3. Why should retries be limited and use jitter?

    Immediate unlimited retries multiply load exactly when the dependency is weakest. Backoff, jitter and budgets spread and cap it.

Summary

  • Choose the pattern from the problem: boundaries, communication, consistency, resilience, operations.
  • Treat resilience numbers as starting points: set timeouts everywhere, retry a few times with backoff and jitter, add breakers and bulkheads, shed load deliberately.
  • Assume at-least-once delivery and write idempotent handlers.
  • Pick a deployment strategy that gives you a fast rollback.
  • Use the production checklist to find the heaviest gaps before launch.

You have reached the end of the track. To review from the beginning, start again at What Are Microservices?.