Design a Top K / Trending Topics System
hard 45 minCount billions of mentions a day and show the ten topics that are rising right now, in each country and city.
Explain your choices
Answer first. Then compare your reasoning.
12 questions 0 got it 0 to review12 not marked
Decisions
Choice, reason, cost, trigger
| Choice | Because | Cost | Change it when |
|---|---|---|---|
| Two stages, two keys | Correct merging, no hot key | Ten more seconds | One machine is enough |
| Gate, then exact | 1% of the memory | Estimates under 20 | Distinct topics fit anyway |
| Minute ring | Smooth hour | 240 bytes | Only daily lists |
| People, not posts | Harder to fake | Memory for repeats | Inputs are trusted |
| Whole lists in Redis | No half update | Rewrite 3 MB | Lists become personal |
| 30 s at the edge | Budget of 60 | Less cache | Target is five minutes |
When they push back
| They say | Answer with |
|---|---|
| "Just use a Redis sorted set." | "For one place and known items, yes. Here it is 417,000 increments a second, 100 million members and a window that slides." |
| "Approximate? Our lists must be right." | "The listed counts are exact after 20 mentions. The estimate only decides who gets a counter, and it cannot miss anyone." |
| "Why Flink?" | "I need keyed state, event time and checkpoints. A plain consumer with a local store does it too, with more of our own code." |
| "Is a minute too slow?" | "55 of 58 seconds are timers. I can halve each, for more work and more edge traffic." |
| "Who decides what is suppressed?" | "A written policy and people, with a log. The system holds and shows evidence." |