How the interviewer opens it
“Design a system that tracks exceptions from a service. It must return the K most frequent and K least frequent exception types within a sliding time window.”
The prompt is vague on purpose. The first minutes are for you. Reduce the prompt to the core features and agree on the numbers before you draw.
What to clarify first
- Exception identity
- Window definition
- Rank semantics
- Event volume and cardinality
- Query volume and read:write mix
- Event time and freshness
- Latency
- Consistency and availability
- Durability and duplicates
- Service boundary and exclusions
The interviewer has the answers. In a SysRound round, Alex gives these answers, as a real interviewer does.
Scope of a strong answer
Core requirements
- Accept exception events from all instances of one service
- Maintain exact counts within the current time window
- Return the K most frequent and K least frequent exception types, with their counts
Usually out of scope
- Collect exceptions from application code
- Derive exception types from stack traces
- Search raw stack traces
- Query arbitrary historical intervals
What interviewers ask about
- The current time window
- Every event must enter and leave the exact window once. Late arrivals and worker delays make wall-clock expiry unsafe.
- The least frequent exceptions
- Rare types constantly enter and leave the active set. The system must exclude zero counts while counts change in both directions.
- Results across workers
- Counts must cover every service instance. Partial ranks and mismatched window endpoints can produce plausible but incorrect global results.
- Counts after a failure
- A retry can duplicate an increment or an expiry. Recovery must preserve both counts and progress through the input.
Common mistakes
- The design treats zero-count types as the least frequent exceptions.
- The design uses fixed windows instead of a sliding window.
- The design selects local ranks before it combines counts for each exception type.
- The design uses an approximate sketch despite the exact-result requirement.
- The design combines partition results from different window endpoints.
- Replay changes counts because state and input progress disagree.
The bar by level
- Senior (L5/E5)
- Partitions complete counts by type. Explains exact candidate merges, late events, ordered index updates, and checkpoint recovery. Returns one complete window across workers.
- Staff (L6+/E6+)
- Defines when results become visible during delay, recovery, and owner changes. Quantifies bucket state and query costs. Adapts to skew without losing exact counts.