KatInterview

Build a Real-Time Error Aggregation Service with Top-K Tracking

System DesignModel answer
MediumModel answerSystem Designdistributed-systemsstreamingdata-pipeline

Last updated

Design a distributed system that ingests exception logs from microservices, groups similar errors, and maintains a live top-10 most common exceptions dashboard.

Challenge

You need to architect a monitoring service that processes error reports from a large fleet of microservices and presents a live dashboard showing the 10 most frequently occurring errors in the past hour.

Requirements

Core Functionality

  1. Accept exception reports at a rate of millions per second
  2. Group similar errors together using an intelligent matching strategy
  3. Track rolling counts over a 60-minute window
  4. Expose an endpoint to retrieve occurrence counts for any error pattern

Quality Attributes

  1. Must remain operational through individual component failures
  2. Ingestion should be fast; processing can happen asynchronously
  3. Scrub sensitive information like email addresses and user IDs from stack traces
  4. Handle sudden traffic spikes without dropping data

What to Cover

  • How you'll structure both the incoming events and the aggregated statistics
  • Your pipeline for receiving, normalizing, and grouping errors into categories
  • The mechanism for computing top-10 rankings continuously as new data arrives
  • Storage choices balancing immediate query needs against historical analysis

Hints

Hint 1

Consider how grouping reduces the number of distinct items you need to track—this affects whether you need approximation algorithms

Hint 2

Think about pre-aggregating before writing to your main processing layer to avoid overwhelming downstream components with repetitive data

Hint 3

For a rolling time window, circular buffers of time buckets let you efficiently add new data and remove expired data