Brokerage
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 a brokerage app (Robinhood): the 60-second story

    Design a brokerage app

    It’s 09:15. Two million phones open the app at once.

    Prices must reach every screen. Orders must never be lost, doubled or sent without the money. Two paths, opposite rules.

    800M

    price messages a second, sending every tick

    2 million connections × 40 symbols; assume 10 ticks a second at the open. Send only the 10 on screen, at most 4 a second, and it’s 80 million.

    24 ticks in one second. The phone gets four.

    The gateway keeps one slot per symbol, overwritten by each tick. Every 250 ms it sends the newest. A slow phone just gets fewer.

    Bad: Send, then save

    Crash in between: a live order nobody recorded. Retry: it’s sent twice.

    Good: Key, then one transaction

    A retry finds its key. Order, money block and outbox row commit together; the connector sends.

    Asha has ₹50,000. Her phone and laptop buy at once.

    ₹30,500 + ₹30,000 won’t both fit. Checking and blocking are one write, so the second order sees ₹19,500 left and fails.

    The exchange link drops right after order c-77 leaves. Resend under a new ID?

    The trick

    That buys 40 shares, not 20. Keep c-77: the numbered session replays the confirmation and fill you missed.

    25,000

    orders in the busiest second after 09:15

    56 times the day’s average of 444 a second, and over long before an autoscaler could add a server.

    Plan for 09:15 instead of reacting

    1. Pre-scale and warm caches by 08:45
    2. Drain overnight orders in the pre-open
    3. Cancels first; never drop an accepted order
    4. Ten cells: a bad one hurts a tenth of customers

    Remember

    Prices can skip: send what’s on screen, newest only. Orders can’t: block the money as you record them, send once, reconcile nightly.