No caching
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 · 9 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.

    What does a 95% hit ratio do for 50,000 reads a second?

      How high could the hit ratio get for 12,000 hot products?

        The database handles 8,000 reads/s. How many cache shards can you lose?

          A 60 s edge TTL, 2,000 hot pages, 50 locations. What reaches the origin?

            Build-up · 6 steps

            Cache the product page, layer by layer

            From a database that scales with page views to one that scales with changes, and a plan for the day the cache isn’t there.

            Step 1 of 6

            Every read hits the database

            50,000 product reads a second become 50,000 queries, so the database runs near 85% CPU and every request waits 20 ms.

            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 database is at 90% CPU and 98% of queries read the same 12,000 products. What do you add?”

              Your move. Pick an approach:

            2. Deep dive 2 of 4

              Interviewer

              “Sellers edit prices and expect to see the change at once. How does the cache learn about an edit?”

              Your move. Pick an approach:

            3. Deep dive 3 of 4

              Interviewer

              “During the sale, a hot product’s key expires and every request that sees the miss queries the database at once. What do you add?”

              Your move. Pick an approach:

            4. Deep dive 4 of 4

              Interviewer

              “Redis restarts mid-sale. At 95% hits, what happens to a database that handles 8,000 reads a second?”

              Your move. Pick an approach: