Design an order relay service in front of a broker API
I was asked this
No reports yet. Sign in to say where you were asked it.
A system design interview question asked in Databricks's system design round, last asked Apr 2026. It tests apis, reliability and workflows.
Clients send buy and sell stock orders to your service, each with a deadline. The service forwards each order to a third-party broker's API, tracks it until it fills, and cancels whatever has not filled by its deadline. Design the service: the order lifecycle, how you learn about fills, retries, and what happens when the broker is slow or down.
Requirements
- Functional: accept an order (symbol, side, quantity, limit price, deadline) and return an order ID; submit it to the broker; track partial and full fills; cancel the remaining quantity at the deadline; let clients query an order's status and cancel it early.
- Every order is placed with the broker at most once, even across retries and restarts; the service's record of fills matches the broker's.
- Non-functional: deadlines are honored within a few seconds; the broker has rate limits and sometimes times out or goes down; no order is lost if the service crashes.
Clarifying questions
- Does the broker support callbacks or webhooks for fills, or only polling?
- Does the broker accept a client order ID for idempotent submission?
- How many orders per second, and what are the broker's rate limits?
- If the broker is down at the deadline, what should the client be told?
- Are partial fills possible, and how is the remaining quantity handled?
What a strong answer covers
- An order state machine: received, submitting, open, partially filled, filled, cancel requested, cancelled, rejected, expired, with fills recorded as events.
- Durable order records written before calling the broker, and submission with a client order ID so a retried submit cannot create a second order; reconciling unknown outcomes after a timeout by querying the broker.
- Polling versus callbacks: callbacks for latency, polling as a safety net, and idempotent handling of duplicate or out-of-order fill events.
- A deadline scheduler (a durable timer or a queue ordered by deadline) that sends cancels, and the race between a cancel and a late fill.
- Rate limiting and backoff toward the broker, and a circuit breaker when it is down.
- Periodic reconciliation of open orders and fills against the broker.
Follow-ups
- The service crashes after sending an order but before saving the broker's response. What happens on restart?
- Support several brokers and route each order to the best one.
- A client sends 10,000 orders at once. How do you stay within the broker's limits fairly?
Where it's asked
- Databricks · System design · Last asked Apr 202660 min · Design discussion, often written in a Google Doc rather than on a whiteboard
What it tests
apis · reliability · workflows
No official answer yet. Draw yours on the right; publish it and it shows under Community.
Nothing published yet. Publish your canvas and it shows here for others to open and remix.
