Why should a Trace-ID be 128 bits? (A Surprisingly Long Answer)

· ai · Source ↗

TLDR

  • 128-bit trace IDs exist because coordination-free random generation requires a collision space so vast that the birthday paradox never becomes a practical threat.

Key Takeaways

  • Trace IDs are generated independently at each service entry point and propagated via headers like traceparent; no central counter is feasible.
  • Collision risk follows the birthday paradox formula P ≈ 1 - e^(-k²/2N); with 64-bit IDs, a billion traces already hits ~2.7% collision risk.
  • 128-bit space (N = 2¹²⁸ ≈ 3.4×10³⁸) keeps k²/2N near zero even at quadrillion-scale trace volumes.
  • 256 bits would double storage and bandwidth on every span, header, log line, and index with no realistic safety gain over 128.
  • 128 bits matches UUID size, meaning every database, language, and protocol already handles it natively.

Hacker News Comment Review

  • No substantive HN discussion yet.

Original | Discuss on HN