KatInterview

Build a Fleet-Wide Error Frequency Tracking Platform

System DesignModel answer
MediumModel answerSystem Designsystem-designstreamingaggregation

Last updated

Design a shared platform that ingests error logs from many apps, collapses similar messages into one signature, and answers count, trend and top-N queries reliably during incident spikes.

Your company runs hundreds of services, and each one emits error messages. You are asked to design a central platform that tells engineers how often each kind of error is happening.

Two raw messages that describe the same underlying problem rarely look identical. They may contain different request IDs, user IDs, timestamps, hostnames or numeric values. The platform must still treat them as one error.

Design the platform end to end. Your answer should cover:

  • How a raw message becomes a stable grouping key (a signature), and which extra dimensions (service, region, release version) are counted alongside it.
  • How the write path handles steady load and sudden incident bursts, where error volume can jump by 10x to 100x.
  • How counts are stored and queried: count of one error over a time range, a per-error time series, and the top N errors in a recent window.
  • How you deal with retries, late or out-of-order events, and component failures, and what accuracy guarantee you offer.
  • Rough capacity estimates, retention and rollup policy, and how you would monitor the platform itself.

State your assumptions about scale and freshness up front, and mention which clarifying questions you would ask first.

Hints

Hint 1

Start by defining the counting key: a normalized message template plus service and a time bucket. Think about what to strip out (IDs, numbers, timestamps, paths) and whether to prefer a client-supplied error code or stack-frame hash when one exists.

Hint 2

Never write once per error to the database. Put a durable partitioned log in front, then pre-aggregate in memory over short windows (for example 10 seconds) so a burst of a million identical errors becomes a handful of increments.

Hint 3

Store counts in fixed time buckets (minute, hour, day) with rollups and different retention for each. Top-N over a recent window is a separate query shape: consider a per-window heap or a sketch rather than scanning every signature.

Hint 4

For correctness, decide your delivery semantics. At-least-once delivery plus idempotent bucket writes (keyed by partition and offset range) gives effectively exact counts; also decide how long late events are accepted.