Denormalization
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 · 5 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 counting “ordered 12k times” live on every menu cost?

      Build-up · 5 steps

      Keep a hot counter correct and fast

      Every order bumps dishes.times_ordered. Watch two orders race, then a one-rupee biryani offer arrive.

      Step 1 of 5

      Read, add, write loses one

      The app reads times_ordered = 1200, adds 1 and writes 1201. Two concurrent orders both write 1201, and one increment is gone. That’s a lost update.

      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

        “Dish search documents need the restaurant’s name, and restaurants get renamed. How do you keep that copy right?”

        Your move. Pick an approach:

      2. Deep dive 2 of 4

        Interviewer

        “Menus show “ordered 12k times”. Order lines are inserted by the API, an admin tool and bulk imports. How do you maintain times_ordered?”

        Your move. Pick an approach:

      3. Deep dive 3 of 4

        Interviewer

        “A restaurant sales dashboard aggregates millions of order lines on every load. Numbers a few minutes old are fine. What do you build?”

        Your move. Pick an approach:

      4. Deep dive 4 of 4

        Interviewer

        “On DynamoDB, a restaurant’s name is copied into thousands of items, and the restaurant is renamed. How do you update the copies?”

        Your move. Pick an approach: