Back to problems

Track Top-K Frequent Elements from an Unbounded Stream

System Design · Salesforce · Hard

Design a continuously running service that ingests events from an endless stream. At arbitrary times, a client can ask for the k values with the largest occurrence counts, and the service must answer from a consistent snapshot even while new events continue to arrive. Define the exact contract before describing the implementation: result format: up to k pairs (element, count) ordered by descending count; whether a query can race with ingestion and how snapshot consistency is…

Checking your access…