System designInterview preparation
Advanced·System design·2 min read

How would you design an order-book-like matching system?

Practice this question

Short explanation:

An order-book matching service accepts orders and matches eligible buyers and sellers according to explicit market rules. In a simple price/time model, price determines priority first and accepted sequence resolves equal-price competition. Correct ordering, durable records and deterministic recovery matter more than maximizing concurrency within one book.

Key points:

  • Clarify matching, allocation, cancellation and market rules first.

  • For a simple price/time model: best eligible price first, then earliest accepted order.

  • Serialize matching per instrument, record durable events and prevent duplicate submissions.

  • Handle partial fills and recovery deterministically; scale across independent instruments.

  • Use exact price/quantity representations and define how cancellations, partial fills and duplicate submissions are ordered.

  • Separate independent instruments for scale, and replay durable accepted events after a failure to rebuild consistent state.

Interview point:

  • Clarify that IPO allocation rules may differ from continuous matching; do not assume one domain's rules apply to every offering.
Adapted from 07_SYSTEM_DESIGN_ARCHITECTURE.md · “How would you design an order-book-like matching system?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.