Api Design hard
Your API is deployed in US-East and EU-West with regional databases. A user in US creates an order, then immediately calls EU API to list orders (routed by DNS). The new order is missing. Why?
- A The mismatch is caused by cross-region replication lag, as the asynchronous data synchronization between the US and EU databases hasn't completed during the read-after-write window.
- B The order was successfully persisted in the US region but was discarded by the EU database due to a primary key collision caused by an uncoordinated UUID generation algorithm.
- C An intermediate CDN or Edge proxy has cached the empty order list for that specific user, preventing the request from ever reaching the fresh data stored in the EU regional database.
- D The global DNS provider has misrouted the request to a legacy staging environment in the EU region that is not configured to participate in the production data replication ring.
Answer: A. The mismatch is caused by cross-region replication lag, as the asynchronous data synchronization between the US and EU databases hasn't completed during the read-after-write window.
In a multi-region active-active setup (e.g., DynamoDB Global Tables or geo-replicated SQL), data replication is asynchronous to avoid latency penalties. This leads to **eventual consistency**. A user writing in Region A and reading from Region B immediately might not see the new data due to **replication lag**. Strategies to mitigate this include 'sticky' routing (route user to same region) or 'read-your-writes' consistency models.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- You're designing a REST API for a blog. Which endpoint best represents 'get all comments for post 123'?
- A client wants to update only the 'status' field of an order, leaving other fields unchanged. Which HTTP method is most appropriate?
- A client calls POST /users with valid data, and the user is created. What status code should the server return?
- A client retries a failed 'POST /payments' request due to network timeout. The server receives the request twice. Without idempotency handling, what can happen?
- An API returns 10,000 products. Returning all in one response is impractical. Which pagination approach is simple and stateless?
- Your API serves both mobile apps and third-party integrations. Which authentication method is most appropriate?