Caching 101
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 · 7 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.

    Cache 0.5 ms, database 10 ms, 90% hits. What’s the average read?

      What hit ratio does a 200,000 reads a second sale need?

        How much memory does the product working set need?

          Build-up · 5 steps

          Follow one look-aside read

          The app asks the cache first and fills it on a miss. Facebook calls its memcache a demand-filled look-aside cache.

          Step 1 of 5

          Ask the cache first

          The app looks the key up in the cache. Only data somebody asked for gets cached, so memory goes to what is actually used.

          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 2 of 4

            Interviewer

            “Mid-sale, Redis goes down. Traffic is 200,000 reads a second and Postgres comfortably serves 10,000. What’s your plan?”

            Your move. Pick an approach:

          2. Deep dive 3 of 4

            Interviewer

            “You’re bringing a brand-new cache cluster into service before a sale. How do you switch it on?”

            Your move. Pick an approach:

          3. Deep dive 4 of 4

            Interviewer

            “Each app server keeps its own in-process cache. Database load grows every time you add servers, and deploys hurt. What do you change?”

            Your move. Pick an approach: