Design a stock exchange from an empty canvas: orders through a gateway and a risk check into a matching engine, market data fanned out to every subscriber, all in a few milliseconds.
Unlock it once for 25 credits; everything inside it is free (runs, changes, Submit, results, hints). Sign in with Google to start; new accounts get free credits.
What it must do
Accept orders and cancels from brokers through an order-entry gateway, with a pre-trade risk check.
Match orders in strict price-time priority, one order book per symbol.
Publish every trade and book change as market data to every subscriber.
Serve the latest quote for a symbol.
Acknowledge an order in a few milliseconds, even at the opening bell.
Scale
3,000 messages a second: 1,800 new orders, 750 cancels and 450 quote requests.
Every order and cancel changes a book: 2,550 market-data updates a second to fan out.
The opening bell brings 4× the traffic for 8 seconds.
Request types to route: order (60%, write), cancel (25%, write), quote (15%, read). Budget: $6,800 a month.
Estimate first
Orders and cancels a second at the opening bell (4×) (msg/s)
Market-data messages a day if every update reaches 1,000 subscribers for a 6.5-hour session (billion)
p99 left for matching and queueing if the load balancer, gateway, risk check and publish take 1 ms each, against a 12 ms target (ms)
Monthly cloud cost of your design (USD)
The test cases
You start from an empty canvas. When you run the tests, each one simulates your design with its own traffic and failures:
Test
What it does
Passes when
Normal day
The normal day: the traffic in the brief, nothing broken.
Success ≥ 99.9%; p99 latency ≤ 12 ms (order); p99 latency ≤ 12 ms (cancel); p99 latency ≤ 15 ms (quote)
The opening bell
At 5 s the market opens: traffic jumps to 4× for 8 s.
Success ≥ 99.9%; p99 latency ≤ 20 ms (order); p99 latency ≤ 20 ms (cancel)
A server dies
At 4 s one server of the first app service on the request path dies for 10 s.
Success ≥ 99.9%; p99 latency ≤ 15 ms (order)
Budget: $6,800/month
The normal day's design must cost at most $6,800 a month.
Cost ≤ $6,800/month
Must include
A matching engine. Orders for one symbol are matched one at a time in price-time order; the engine keeps each book in memory.
A market-data stream. Every book change goes, in order, to every subscriber: a sequenced stream fanned out to them.