All Questions
Api Design hard

Your API creates an order (POST), which triggers async processing (inventory, payment). GET /orders/123 right after POST might return 'pending' even though payment already succeeded in the backend. How do you handle this?

  1. A Explicitly document the state-machine transitions and provide clear status codes, while offering a Server-Sent Events (SSE) or WebSocket stream for real-time state notifications.
  2. B Enforce a strictly synchronous execution model that blocks the initial POST request until the entire downstream transaction chain has been successfully committed and verified.
  3. C Temporarily suppress the visibility of the new resource until a background consensus check confirms that all regional replicas have achieved a uniform and consistent data state.
  4. D Implement a 'Optimistic Completion' strategy where the API returns a fake 'Completed' status to the client, while silently handling any asynchronous failures in a dead-letter queue.

One system design question a day, with spaced repetition so the ones you miss come back.

Get the app

Related questions