Counting sounds simple. Increment a number when something happens. How hard can it be?
At small scale, counting is trivial. A single database column, an UPDATE counter = counter + 1, and you're done. But the moment you need to count millions of events per second across dozens of servers, everything breaks down.
This problem shows up everywhere. YouTube counts video views. Twitter counts likes and retweets. Reddit counts upvotes. Instagram counts followers. Amazon counts inventory.
Every high-scale system eventually faces the question: how do you count things reliably when millions of events happen simultaneously?
The challenge isn't the counting itself. The challenge is doing it fast, accurately, and without creating bottlenecks that bring your entire system to its knees.
In this chapter, we'll explore the distributed counting pattern: the fundamental approaches, their trade-offs, and when to use each one. This pattern appears constantly in system design interviews because it tests your understanding of consistency, scalability, and the practical trade-offs that define distributed systems.