Serving Daily-Changing Prices to a High-Traffic Launch Page
System DesignModel answerLast updated
Design the API and serving layer for product prices that change at most once a day but are read at very high rates, with atomic publishing, caching, rollback and checkout correctness.
You are building the backend that supplies prices for an online store's product launch page. Each product's price can change at most once per 24 hours, yet the launch page must render quickly for a very large audience, and it often needs prices for many products in one go.
Design the API and the serving system.
Given
- Reads vastly outnumber writes.
- A product has at most one price change per day.
- A single page view may need prices for many products at once.
- Priorities: low read latency, and prices that are consistent once published.
What to cover
- Clarifying questions you would ask, and the assumptions you would state (catalog size, products per page, traffic peak, latency target, scheduled vs. manual changes, how fresh prices must be after a change).
- The public read API and the internal write/publish API, including how money is represented and how retries are handled.
- The data model and how the one-change-per-day rule and an audit history are enforced.
- The end-to-end architecture for the write path and the read path.
- How a set of price changes becomes visible atomically, how a scheduled change at a specific time avoids a stampede, and how you roll back a bad release.
- What happens at checkout, where the displayed price and the charged price must agree.
- Failure behavior and the main trade-offs you are making.
Hints
Hint 1
Estimate the data size first. If the whole catalog is around 100 MB and the page payload is a few tens of KB, what does that suggest about the need for a heavy database on the read path?
Hint 2
Think of a release as an immutable, versioned snapshot plus a single pointer to the current version, instead of invalidating individual product entries one at a time. What does this buy you for consistency and rollback?
Hint 3
For the scheduled-change stampede, consider building and pre-warming the next version before the effective time so that the moment of change is only a pointer flip. Then decide how checkout treats a price version the user saw a few minutes ago.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Clarify and size the problem
Questions to ask: how many products exist and how many appear on the launch page; whether changes are scheduled or manual; how stale a displayed price may be after a change; whether the page payload can be precomputed per region/currency; peak traffic and latency targets.
Assumptions I would state:
- 1M products, about 500 on the launch page.
- At most 1M changes/day (about 12/s average), mostly scheduled for a fixed moment such as 00:00 UTC, so write bursts can reach thousands per second.
- Peak around 100k page loads/s; p99 under 50 ms at the edge, under 10 ms at origin.
- A page must never show a mix of old and new prices from the same release. A few seconds of staleness after publishing is fine. Checkout must charge a correct, verifiable price.
Key observation: the data is small and slow-moving. 1M prices at roughly 100 bytes is about 100 MB, which fits in RAM on every server. The launch payload is about 50 KB (roughly 10 KB compressed), ideal for a CDN. So this is a publishing problem, not a database-scaling problem.
2. API
Write path (internal, authenticated):
PUT /v1/products/{id}/price
{ amount_minor, currency, region, effective_at, release_id, idempotency_key }
-> 202 { price_id, status: "SCHEDULED" }
POST /v1/price-releases/{releaseId}/publish -> { snapshot_version }
POST /v1/price-releases/rollback { to_version }
Read path (public):
GET /v1/pages/launch/prices?region=US¤cy=USD
-> { version, generated_at, prices: { id: {amount_minor, currency} } }
ETag: "v42"; Cache-Control: public, max-age=10, stale-while-revalidate=60
GET /v1/prices?ids=a,b,c -> batch read with the same version field
Design points: store money as integer minor units plus currency, never floats; require idempotency keys so retries are safe; return a version in every read so clients and checkout can detect mismatches.
3. Data model
prices(SQL, source of truth): price_id, product_id, amount_minor, currency, region, effective_from, status (DRAFT/SCHEDULED/LIVE/SUPERSEDED), release_id, created_by, created_at.price_releases: release_id, status, scheduled_at, published_at, snapshot_version.- Snapshots in an object store: immutable files like
prices/launch/US/USD/v42.json. current_pointerin a strongly consistent KV store:launch:US:USD -> 42.
The one-change-per-day rule is a unique index on (product_id, region, effective_date). History is append-only, which gives the audit trail for free.
4. Architecture
Admin/Scheduler -> Write Service -> SQL --outbox--> Queue -> Snapshot Builder
-> object store (v{n}) + pointer flip
Client -> CDN -> Read Service (in-memory snapshot, hot-swapped)
Write path: validate (currency, bounds, daily limit); write the row and an outbox event in one transaction; the builder materializes the full payload per page/region/currency ahead of the release time; it runs sanity checks (no negative prices, no change above X% without an approval flag); writes the immutable object; then flips the pointer.
Read path: the CDN serves the launch payload so most requests never hit origin. Origin instances keep the entire current snapshot in memory, watch the pointer, load the new version in the background, and swap one reference atomically. Batch reads are map lookups. No database sits on the read path.
5. Deep dives
Atomic visibility. Immutable snapshots plus one pointer flip mean a reader sees all of v41 or all of v42. Per-product invalidation would produce torn pages where some items are new and others old.
Scheduled changes without a stampede. Build v42 minutes early and pre-warm the CDN at its versioned URL. At the effective time only the pointer moves. Expose it either through a tiny short-TTL manifest that references a long-TTL versioned object, or by serving the page endpoint with max-age=10 and stale-while-revalidate plus request coalescing, so each edge makes one origin fetch per TTL.
Rollback. Because old snapshots are immutable, rollback is just pointing back to v41. It takes effect within the cache TTL and requires no data rewriting. The rollback is itself recorded in the audit log.
Availability. Aim for a CDN hit ratio above 99%. The origin is stateless and memory-only, so it scales horizontally. If the pointer store is unreachable, keep serving the last known snapshot (favor availability for reads). Replicate the object store and deploy across regions.
Checkout correctness. The page price is a display price. Checkout re-resolves the price from the authoritative service. To honor what the shopper saw, accept the displayed version within a grace window (say 15 minutes). That avoids overcharging people on a stale page while preventing abuse of old caches.
Write safety. Replicated SQL with the outbox pattern ensures no update is lost between the database and builder. Require two-person approval for large deltas.
6. Trade-offs
- Precomputed payload vs. per-product caching: precomputing gives the fastest reads and atomic consistency; rebuilding everything on change is cheap at one change per day.
- Purge vs. TTL + versioned objects: purges are faster but less reliable; short TTLs bound staleness to about 10 s and are simpler.
- Consistency: snapshot consistency with bounded staleness for display, strong consistency at checkout.
- In-memory replica vs. Redis: at 100 MB, local memory is faster and has fewer failure modes. Move to sharded Redis only if the catalog grows by orders of magnitude.
7. Common mistakes
- Invalidating cache entries one product at a time, leading to inconsistent pages.
- Using floats for money.
- Letting every request hit the database at the moment of a scheduled change.
- Trusting the cached display price at checkout.
- No rollback plan, or a rollback that requires rewriting data.
- Over-engineering a sharded store for a 100 MB dataset.