← eBay Interview Insights

eBay·Software Engineer·Onsite - System Design / Architecture·Senior

SeniorPrefer not to say
Jun 2026

Summary

eBay system design round, one big question that kept expanding. Started with a simple top-K counter and by the end we were talking about distributed sharding, sketch algorithms, and windowed aggregation. Felt like I was always one step behind where they wanted me to be.

Questions Asked (1)

Q1

Design a distributed service that returns the top-K most frequent items over a high-throughput event stream. Cover the API, ingestion pipeline, approximate counting with sketches, sharding and merging, and time-window semantics.

System DesignAlgorithms & Data StructuresTechnical Trade-offs
Author's notes

This started manageable and then just kept growing.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: throughput, K, accuracy, time windows, and query patterns. Then propose a sharded ingestion pipeline where each shard maintains a Count-Min Sketch (or Space-Saving) for approximate counting, and a merging layer aggregates per-shard top-K candidates. Finally, discuss time-window semantics (tumbling/sliding) and trade-offs between accuracy, memory, and latency.

Pro tip: Emphasize that exact top-K over a high-throughput stream is infeasible at scale, so approximate algorithms with bounded error are the pragmatic choice—and explain how to merge sketches across shards without losing accuracy guarantees.

1. Clarify requirements and constraints

Ask about event rate, K value, acceptable error, time-window definitions (tumbling vs. sliding), and query latency. This scopes the design and shows you avoid premature optimization.

2. Design API and ingestion pipeline

Define endpoints for querying top-K (e.g., GET /topk?window=5m&k=10) and for ingesting events. Describe a partitioned message queue (Kafka) feeding stateless ingestion workers that route events to shards by key.

3. Choose approximate counting and sharding strategy

Propose Count-Min Sketch or Space-Saving per shard for memory-efficient frequency estimation. Explain sharding by item hash to distribute load, and how each shard maintains its own sketch.

4. Implement merging and query layer

Describe a merger service that periodically collects per-shard top-K candidates (or merges sketches) and computes the global top-K. Discuss merge frequency, consistency, and caching for low-latency queries.

5. Address time-window semantics and trade-offs

Explain how to support tumbling windows (fixed buckets) and sliding windows (overlapping buckets or decay). Discuss trade-offs: sketch size vs. accuracy, merge overhead vs. freshness, and memory vs. throughput.

Key Points to Mention

  • Count-Min Sketch or Space-Saving algorithm for approximate frequency counting with bounded error
  • Sharding by item key to parallelize ingestion and counting, with per-shard sketches
  • Merging strategy: combine per-shard top-K candidates or merge sketches, handling duplicates and error propagation
  • Time-window semantics: tumbling vs. sliding windows, bucketization, and expiration of old data
  • Trade-offs: accuracy vs. memory, latency vs. freshness, and exact vs. approximate counting
  • Scalability: partitioning, replication for fault tolerance, and backpressure handling in the ingestion pipeline

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.