Prevent Lost Updates on Seller Listings With ETags and If-Match
Last updated: November 29, 2026
Quick Overview
Two tools edit the same seller listing: one lowers the price while another changes quantity, and the second save silently erases the first. Add ETag-based optimistic concurrency to the REST resource, plus conditional GETs for caching.
Amazon
November 29, 20260
0
0 solved
Two tools edit the same seller listing: one lowers the price while another changes quantity, and the second save silently erases the first. Add ETag-based optimistic concurrency to the REST resource, plus conditional GETs for caching.
Sellers edit listings from Seller Central, spreadsheets, and third-party inventory tools at once, so last-writer-wins clobbers data. The interviewer is checking HTTP conditional request semantics, correct status codes, and an atomic compare-and-set on the server.
What the Interviewer Expects
- Explains the lost update when both clients read the same version
- Returns an ETag on reads and requires If-Match on updates
- Performs compare and write atomically
- Uses 412 for a stale tag and 428 when the precondition is missing
- Uses If-None-Match and 304 to save bandwidth on reads
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- Should the ETag be a content hash or a version counter, and why?
- How would you let the client merge instead of forcing a full re-edit after a 412?
- How does this map to a DynamoDB conditional write?
- What changes for PATCH requests that touch disjoint fields?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
GET /listings/{id}returns the document with anETag;If-None-Matchwith a matching tag gets 304.PUTmust carryIf-Match; a stale tag gets 412 with the current version so the client can...
High-Level Design
The ETag is a hash of the canonical JSON, so identical content yields identical tags. put checks the tag and writes under one lock, the in-process equivalent of a conditional update. On 412 the resp...