Bookstore Batch Book-Price API
Design a read-only HTTP API that returns current prices for a bounded batch of bookstore editions with explicit freshness and partial-result semantics.
Problem statement
For this exercise, assume bookstore clients need one read-only HTTP operation that fetches the current selling price for as many as 500 unique book-edition IDs.
Clients send a structured JSON request with edition IDs and one supported display currency; the response preserves request order and gives each edition a found, not-found, or temporarily-unavailable result. A found result includes integer minor-unit amount, currency, price version, and effective time.
Malformed, duplicate, or oversized batches fail as a whole, while a valid batch may return item-level partial results when one price partition is unavailable.
The price service owns the current committed price, receives versioned updates from a merchant pricing system, and may serve cache entries no more than 30 seconds stale. A batch is not an atomic price snapshot across editions.
Explain why this safe, idempotent read uses POST with a JSON body rather than GET, and define the resulting retry and cache behavior. Assume 50 million editions, peaks of 20,000 batch requests and 5,000 price updates per second, an average batch of 100 editions, and a 150 millisecond p95 response target.
Catalog search, inventory, carts, ordering, payment, promotions, tax, and checkout are outside scope.
What to build
- Authorized clients can submit up to 500 unique edition IDs and receive ordered per-item current-price results in one HTTP response.
- The API defines why the structured batch read uses POST, while preserving safe idempotent retry semantics and explicit cache behavior.
- A merchant pricing system can publish versioned price changes that become visible to reads within the declared freshness bound.
- A valid request reports found, not-found, and temporarily-unavailable outcomes per edition without disguising partial service failure as missing data.
At scale
- For this exercise, assume 50 million sellable book editions and 5,000 versioned price updates per second.
- For this exercise, support peaks of 20,000 batch requests per second, averaging 100 and allowing at most 500 unique edition IDs per request.
- For this exercise, target 150 milliseconds p95 for an accepted batch read and 99.9 percent monthly availability.
- For this exercise, a cached price may be at most 30 seconds stale, and a batch does not promise an atomic snapshot across editions.