</> MAANG.io
system design · 301

Advanced

Master system design interviews with scalable architecture patterns, distributed systems, and real-world design challenges.

0/480 solved 0% complete

Section 7: Eleventh Everywhere, First Overall - Exact Sliding-Window Top-10 (Candidate-Driven)

Executive Summary: Handed the wheel, the candidate dives into the speed path first, because a wrong Top-10 still looks plausible. Five dives follow. Keying by productId turns "merge the local Top-10s" from a classic bug into an exact algorithm. Minute buckets plus running counters give exact 1h, 4h and 24h sliding windows that can go down as well as up. Event time, a fast minute clock and a 2-minute settle watermark absorb stragglers and cancellations without delaying the list. Checkpoints, dedup and version-checked writes make each list exactly-once. A top-20 cushion lets serve-time filtering run without leaving gaps. The lesson: an exact streaming Top-K is cheap once the partitioning makes it exact by construction.

Choosing Where to Dig

Section 6's diagram is up on the board. The interviewer hands you the floor: "Where do you want to go deeper?"

You: "The speed path first. When the rank path is wrong you can see it: two #13s on a page. When the speed path is wrong, you get a confident Top-10 with the wrong products on it. It has four quiet failure modes: the merge across partitions, windows that must forget, late or cancelled events, and failures that double-count. Section 8 can have '#1,056'."

Picking the dive where errors are invisible tells the interviewer you know where production bugs hide.

Sign in to continue reading

The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.

Sign in to read the full lesson

Sign in to MAANG.io

Use your Google or Microsoft account — no password to remember.

Continue with Google Continue with Microsoft

Please accept the terms above to continue.