Hot keys
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Layer 3 · Go deeper · 8 min

    Go deeper

    Size it, build it, then make the calls an interviewer will push you on.

    Back of the envelope

    Size it up

    Tap through each step of the arithmetic.

    How hot is a live IPL score key?

      How many queries does one expiry send to the database?

        What does TTL jitter do for 2 million keys loaded together?

          Build-up · 5 steps

          Stop one stampede, fix by fix

          One key read 20,000 times a second, a 200 ms recompute and 200 app pods. Each fix cuts the database queries per expiry.

          Step 1 of 5

          No protection

          The key expires and every request in the next 200 ms misses and queries, 20,000 × 0.2 = 4,000. Concurrent queries slow the database, which lets even more requests miss.

          4 interview moments

          You’re the candidate

          The interviewer pushes on the hard parts. Pick an approach and see how it holds up.

          1. Deep dive 1 of 4

            Interviewer

            “The live-score key takes 400,000 reads a second during an IPL final, and its shard is at 100% CPU. What do you do?”

            Your move. Pick an approach:

          2. Deep dive 2 of 4

            Interviewer

            “A live poll counts 300,000 votes a second on one Redis counter. How do you cool a hot write key?”

            Your move. Pick an approach:

          3. Deep dive 3 of 4

            Interviewer

            “After a bulk catalogue re-import, millions of cached product keys are stale at once. How do you invalidate them?”

            Your move. Pick an approach:

          4. Deep dive 4 of 4

            Interviewer

            “A bot walks never-issued product IDs at 5,000 requests a second. Every request misses the cache. What do you add?”

            Your move. Pick an approach: