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.

    Layer 3 · Go deeper · 12 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.

    How many WebSocket connections just after 09:15?

      How many price messages a second at the open?

        How much bandwidth, and how many stream gateways?

          How many order requests a second at the open?

            How many databases does the order path need?

              Build-up · 5 steps

              Build the high-level design

              One requirement at a time, ending with a broker that works for one market at modest load, in one database.

              Step 1 of 5

              Watch live prices

              Each exchange feed comes in once, onto an in-memory bus with a topic per symbol, deliberately not durable: a second-old price is worthless. Gateways send each phone its symbols, snapshot first.

              6 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 6

                Interviewer

                “Two million phones follow about 40 symbols each, and popular ones tick many times a second. How do you deliver prices?”

                Your move. Pick an approach:

              2. Deep dive 2 of 6

                Interviewer

                “A dozen checks sit between tap and sent, run 25,000 times a second at the open. How do you run them?”

                Your move. Pick an approach:

              3. Deep dive 3 of 6

                Interviewer

                “A process crashes, a phone retries, the exchange line flaps. How do you make sure no order is lost or sent twice?”

                Your move. Pick an approach:

              4. Deep dive 4 of 6

                Interviewer

                “Asha has ₹50,000. Her phone buys ₹30,500 of ACME as her laptop buys ₹30,000 of BETA. What stops both going through?”

                Your move. Pick an approach:

              5. Deep dive 5 of 6

                Interviewer

                “The busiest second after 09:15 is 56 times the day’s average. How do you get through the open?”

                In March 2020 Robinhood went down on two consecutive trading days, when a “thundering herd” brought down its DNS system.

                Your move. Pick an approach:

              6. Deep dive 6 of 6

                Interviewer

                “Your books must agree with the market’s to the share and the paisa. How do you keep portfolios and P&L right?”

                Your move. Pick an approach:

              Build-up · 8 steps

              Follow Asha’s buy order through it

              The money path lives inside a customer’s cell; market data is shared by everyone; reconciliation closes the day.

              Step 1 of 8

              Admit and route

              The gateway authenticates Asha, applies her rate limit and ranks the request: below a cancel, above a chart. Her cell is one of ten, so a bad cell touches 1.5 million customers, not 15 million.