Data layer
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.

    Does one PostgreSQL primary carry the food app’s orders?

      How many writes a second do live rider locations make?

        Build-up · 6 steps

        Run the five questions on food delivery

        The same five questions for every design, in this order. Each answer feeds the next, and the store is chosen last.

        Step 1 of 6

        Name the nouns

        Five or six nouns and how they relate. Mark the aggregate roots, created, owned and deleted together like an order and its items; they usually become tables or partition keys.

        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

          “Food delivery, 3 million orders a day. Payment and order must commit together. Which database is your system of record?”

          Your move. Pick an approach:

        2. Deep dive 3 of 4

          Interviewer

          “One cricket match’s live chat peaks at 5,000 messages a second. In DynamoDB, how do you key it?”

          Every other chat uses the conversation as partition key and the timestamp as sort key. One partition takes 1,000 one-KB writes a second.

          Your move. Pick an approach:

        3. Deep dive 4 of 4

          Interviewer

          ““What if the primary dies?” Payments must never lose an acknowledged write. What do you add?”

          Your move. Pick an approach:

        Build-up · 5 steps

        Place each store in the food app

        One system of record and a few derived or specialised stores, each justified by an access pattern and a number.

        Step 1 of 5

        One system of record

        PostgreSQL takes every business write. About 350 orders a second at peak is comfortable for one primary, and the payment row and the order row commit in one transaction.