← All problems
Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Problem 033 · Observability and operations

Design Distributed Tracing

Medium 50 min

A company runs 1,200 microservices that together handle 400,000 requests per second at the edge, and each request touches about 15 services. Engineers want to open any slow or failed request and see every hop as a timeline. Libraries in each service record spans and send them in batches to your collectors: about 10,000 batches per second at peak, roughly 200,000 spans per second after sampling. Tracing must never slow down or break the services it observes.

Functional requirements

  • Propagate a trace ID across HTTP, gRPC and message hops
  • Collect spans from every service and assemble them into traces
  • Look up a trace by ID and search traces by service, operation, status and duration
  • Keep every trace that contains an error, plus a sample of healthy ones

Non-functional requirements

  • Instrumentation adds under 1 ms per request and never blocks the caller
  • A trace is searchable within 30 seconds of the request finishing
  • Collector or storage outages drop spans rather than affecting production traffic
  • Retain sampled traces for 14 days

Constraints and scale

  • 400,000 requests per second at the edge, about 15 spans per request
  • 200,000 spans per second ingested after sampling, about 1 KB each
  • Roughly 240 TB of span data over the 14-day retention window

You will practise

  • Compare head-based and tail-based sampling and when each one fits
  • Buffer high-volume telemetry with a stream between collectors and storage
  • Model trace storage for fast lookup by ID and indexed search by attributes
Show 3 hints
  1. If you only decide to keep a trace when it starts, how do you make sure you keep the ones that end in an error?
  2. Spans of one trace arrive from many services at different times: where are they grouped before a sampling decision?
  3. Lookup by trace ID and search by attributes are different access patterns; do they belong in the same store?

Ready to build?

Open the canvas, place your components and explain your decisions. Your draft saves automatically.

Sign in to start

Failure scenarios

  • An outage floods the tracing pipelineA payment dependency fails and every checkout request now errors. Tail sampling keeps all error traces, so span volume reaching storage triples in two minutes and the stream's consumer lag starts to climb.

Run them from the workspace once your design is in place.