Skip to main content
InterviewHubPRO
Section Overview
Q38

Question 38 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

76%
SRE & Observability (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

Distributed Tracing Sampling Strategies: Head-based vs Tail-based sampling.

senior LevelSystem Design

In Simple Words: At 100,000 requests/second, recording 100% of distributed traces costs millions of dollars in storage:

  • Head-Based Sampling: Sampling decision is made at the very start of the request (e.g. randomly sample 5% of incoming requests).
    • Fast, low CPU overhead.
    • Major Flaw: A critical 500 error or slow 10-second p99 request might land in the 95% un-sampled bucket and be lost forever!
  • Tail-Based Sampling: Collects all spans in an OTel Collector buffer until the entire request completes:
    • If the request finished with HTTP 200 and latency $< 100 ext{ms}$ -> Discard trace.
    • If the request returned an Error (5xx) OR latency was in the p99 tail (> 2s) -> Always retain 100% of the trace for debugging!