Skip to main content

Distributed Counting / Top K

Difficulty: Hard | Topic #26

What to Learn

Count-Min Sketch for approximate counting, lossy counting, Space-Saving algorithm, two-stage MapReduce approach for heavy hitters; tradeoffs between exactness and memory/throughput.

Resources

Covered by Problems

ProblemDifficultyLink
Top K SystemHard
Ad Click AggregatorHard
Metrics Monitoring SystemHard

Key Concepts to Master

  • Count-Min Sketch — hash table array with minimum estimation
  • Space-Saving algorithm for exact top-K with bounded memory
  • Two-stage approach: local top-K per shard → global merge
  • Bloom filters for membership testing without false negatives issue
  • HyperLogLog for approximate cardinality (unique user counts)