Robinhood
Design Robinhood (Stock Trading Platform)
Robinhood is a real-time financial trading application handling stock price streams and executing high-concurrency buy/sell orders.
1. High-Level Design
The core constraints of a stock trading application are strict transactional consistency (ACID) and sub-100ms real-time pricing streams.
Price Stream: market Stream (Nasdaq) ---> Pricing engine ---> WebSockets ---> Client App
Execution Path: Client Order ---> API Gateway ---> Matcher Service ---> DB Ledger (PostgreSQL)Components
1. Pricing Stream Engine: Connects to Nasdaq/NYSE market data streams. Transforms feed data and pushes real-time price updates to clients via WebSockets or Server-Sent Events (SSE).
2. Order Gateway: Validates order parameters (limit price, account balance, user ID).
3. Execution & Matching Engine: High-performance in-memory matching engine that matches buyer and seller orders.
4. Double-Entry Ledger: A transactional PostgreSQL database recording all balance modifications and security transfers.
2. Potential Deep Dives
- How do you prevent race conditions/double-spending on concurrent bids?
Use pessimistic database locking (SELECT FOR UPDATE) on the user account record during order validation to ensure checking the balance and blocking the trade funds is an atomic operation.
- Ledger Integrity:
Ensure the ledger is append-only. Implement cryptographic chaining (hash chain) to verify historical transaction records have not been modified.
3. References & Tech Blogs
Related Topics
Expand your knowledge by learning about adjacent concepts in system design.
Design a URL Shortener (TinyURL)
Build a high-throughput shortener analyzing base58 encodings and database sharding.
Networking Essentials
Learn the important parts of networking that you'll need to know for your system design interviews
API Design
Learn about API design for system design interviews
Cheat Sheet Utility
View and print a concise system design reference card.