Counting Views at Scale
Decide what you would build from the brief alone. Everything below it is available, but the exercise stops working if you open it first.
Every page view increments a counter. A few items are extremely popular. The single-row update per view is now the hottest write in the database and is causing lock waits across unrelated queries.
Moving the counter to a fast in-memory store to take the write off the database. Throughput improves immediately and two problems arrive: the durable count and the fast count now disagree, with no transaction spanning them, so a restart or eviction silently loses increments; and the hot key is still a hot key — it has moved to a store where a single key is served by a single shard, so the contention is now somewhere with less visibility and no lock-wait metrics.