Problem: Design a Stock Order Manager
Design an order management service responsible for handling stock buy and sell requests. This system will not perform trade matching itself, but instead will integrate with a third-party brokerage API for all order submission and status updates.
Third-Party Brokerage API
The external brokerage provides the following API endpoints:
POST /orders: Submits a new order and returns a unique external order ID.GET /orders/{id}: Retrieves the latest details and status for a given order ID.DELETE /orders/{id}: Requests the cancellation of an existing order.
System Requirements
Your design should support the following core functionalities:
- Order Placement: Facilitate the submission of both buy and sell orders to the third-party brokerage.
- Order Tracking: Maintain and display the status of orders over their entire lifecycle.
- Order Cancellation: Allow users to request the cancellation of existing orders.
- Long-Pending Orders: Gracefully handle orders that remain in a
pendingstate for extended periods. - Expired Orders: Correctly manage orders that expire before being filled.
- Bottleneck Identification & Mitigation: Identify potential system bottlenecks and propose strategies to mitigate them.
Key Focus Areas
Your design should particularly emphasize:
- Order Lifecycle Management: The robust handling of an order's state transitions.
- Correctness under Failures: Ensuring data integrity and operational correctness when dealing with retries or partial failures.
- Consistency with Third-Party: Strategies for maintaining an accurate and consistent view of order status relative to the external brokerage.
AI interview prep
Core dilemma
Maintaining eventual consistency and reliable state synchronization with an external, asynchronous, and potentially unreliable third-party system, while providing a responsive and accurate internal view of order status, especially under retries and failures.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Problem: Design a Stock Order Manager
Design an order management service responsible for handling stock buy and sell requests. This system will not perform trade matching itself, but instead will integrate with a third-party brokerage API for all order submission and status updates.
Third-Party Brokerage API
The external brokerage provides the following API endpoints:
POST /orders: Submits a new order and returns a unique external order ID.GET /orders/{id}: Retrieves the latest details and status for a given order ID.DELETE /orders/{id}: Requests the cancellation of an existing order.
System Requirements
Your design should support the following core functionalities:
- Order Placement: Facilitate the submission of both buy and sell orders to the third-party brokerage.
- Order Tracking: Maintain and display the status of orders over their entire lifecycle.
- Order Cancellation: Allow users to request the cancellation of existing orders.
- Long-Pending Orders: Gracefully handle orders that remain in a
pendingstate for extended periods. - Expired Orders: Correctly manage orders that expire before being filled.
- Bottleneck Identification & Mitigation: Identify potential system bottlenecks and propose strategies to mitigate them.
Key Focus Areas
Your design should particularly emphasize:
- Order Lifecycle Management: The robust handling of an order's state transitions.
- Correctness under Failures: Ensuring data integrity and operational correctness when dealing with retries or partial failures.
- Consistency with Third-Party: Strategies for maintaining an accurate and consistent view of order status relative to the external brokerage.