Cart and checkout
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.

    Design checkout and cart: the 60-second story

    Design checkout and cart

    “Add to cart” must never fail. “Place order” must happen exactly once.

    The cart is always writable. Checkout is exact: a double tap on flaky 4G still means one charge.

    23,000

    cart writes a second when a sale opens

    Against just 1,200 orders a second. The forgiving cart takes about 15× checkout’s traffic, so each half gets the storage and consistency it can afford.

    You removed the phone on your laptop. Why is it back?

    A leaderless store kept both edits as versions; a union merge never loses an add, so deletes resurface. Today’s carts store one item per line.

    Which total do you charge?

    Bad: Re-price, then charge

    FEST500 expires mid-OTP. They’re charged a total they never saw.

    Good: Charge the quote

    Priced once, valid 15 minutes. “Place order” names it and the total shown.

    16M

    units tied up by holding at add-to-cart

    Most sit in carts that will be abandoned. Hold at “Place order” instead, about 1.1M, with conditional updates and holds that expire.

    1,500 “Place order” calls a second. If 0.1% are retries, that’s 5,400 duplicate orders an hour.

    The trick

    The checkout ID is the key: minted when checkout opens, reused on refresh, scoped down every layer.

    Your bank confirms at 20:23. Pay-by was 20:17. Now what?

    Nest the clocks, attempt ≤ pay-by < hold, so a payment in time always finds its stock. A later one re-holds the stock or is refunded.

    Midnight: traffic jumps 10× in a minute

    1. Pre-scale an hour ahead, forecast + 50%
    2. Admit “Place order” at the narrowest pipe’s rate
    3. Shed recommendations first, never cart writes or orders
    4. Bucket the hot stock row and coupon

    Remember

    The cart never refuses a write. Checkout charges a binding quote exactly once: expiring holds, one checkout ID as the key.