Scrivio Interview library
ScenarioIntermediate6 min read · updated 13 November 2026

Sellers change prices in a catalogue database. Search results come from an index updated through change data capture with a typical lag of 40 seconds, while checkout reads the database. Customers complain that the cart shows a higher price than the search results.

Which reads need which consistency here, and how would you change the design and the user experience?

The price charged must come from the authoritative database, so checkout is right; the search index is an eventually consistent copy that lags by about 40 seconds. We keep that split but make it honest: carry a price version with each search result so the cart can detect and explain a change, show any change clearly before payment or honour the shown price for a short window if the business accepts the cost, reduce the lag for price changes specifically, and monitor indexing lag against an agreed bound.

Why this question is asked

Every system that serves search from an index and transactions from a database has two copies of some data, and sooner or later customers notice when they disagree. The engineering instinct is to make the index faster, but the real questions are which read is allowed to be stale, and what the customer should experience when the copies differ. Interviewers ask this to see whether we can combine consistency thinking with product judgement. In this answer, we will look at how the two reads are wired, decide which needs which consistency, then change the user experience, carry versions with prices, reduce the lag where it matters and put monitoring around it.

1How the Two Reads Are Wired Today

Sellers update prices in the catalogue database. Change data capture, a tool such as Debezium reading the database's write-ahead log, turns each change into an event, usually on Kafka, and an indexer applies the events to the search index, for example Elasticsearch or OpenSearch. The typical lag from database commit to searchable change is 40 seconds.

So for 40 seconds after a seller raises a price, search shows the old, lower price while the cart, which reads the database, shows the new, higher one. The customer sees a higher price than the one that brought them in, which feels like a bait and switch even though nobody intended it.

Step throughA price rise reaches the cart before search
SellerCatalogue DBCDC and indexerSearch indexCustomer
price 20 -> 24, commit
change event (lag starts)
search
price 20 (old)
add to cart, read price
price 24
apply change about 40 s later

7 messages in order. Play them, or step through them one at a time.

During the lag, the two reads disagree.

2Which Read Needs Which Consistency

The price charged is a commitment of money, so it must come from the authoritative source at the moment of checkout. Checkout reading the database is correct, and we should not weaken it to match the index. The search index is a derived copy built for ranking and filtering; it is fine for it to be eventually consistent, as long as the delay is bounded and the customer is not misled.

So the design does not need to make search strongly consistent, which would be very expensive. It needs the strong read at checkout, a bounded and monitored lag on the derived copy, and a way to handle the moments when the two disagree.

3Making the Difference Visible and Fair

When the cart price differs from what the user saw, we should say so clearly before payment, for example 'The price of this item changed from 20.00 to 24.00 since you viewed it', and ask the user to confirm. Silently charging the new price erodes trust; silently charging the old one may break the seller's agreement.

Some businesses choose to honour the displayed price for a short window, such as 10 minutes after the user saw it. That is a business decision with a cost, the difference times the number of affected orders, and it needs a limit so a stale price cannot be exploited for hours. Either way, the policy should be explicit and applied the same way every time.

4Carrying a Version With Each Price

To detect a change, the cart has to know which price the user saw. We index each price with a version, either a counter incremented on each change or the commit timestamp, and the search result passes it along when the item is added to the cart. The cart then compares the shown version with the current one.

Java
// search result carries what the user saw
record ShownPrice(String sku, BigDecimal amount, long version) {}
CartLine add(ShownPrice shown) {
Price current = prices.current(shown.sku()); // reads the database
if (current.version() == shown.version()) return line(current, NO_CHANGE);
return line(current, PriceChange.of(shown.amount(), current.amount()));
// shown 20.00 v7, current 24.00 v8 -> cart shows 'price changed from 20.00 to 24.00'
}

Notice that the version also tells us which way the change went, so the cart can treat a price drop and a price rise differently, and it gives support staff a clear record of what the customer was shown.

5Reducing the Lag Where It Matters

We do not need every field in the index to be fast, only prices. One option is to give price changes priority in the pipeline: a separate CDC topic or partition for price updates and a dedicated indexer that applies them with small batches, which can bring the lag down to a few seconds.

A stronger option is to stop relying on the index for the displayed price at all. The index is used for ranking and filtering, and for the 20 or 50 results on the page, the frontend fetches current prices from a fast price service backed by the database or a cache kept up to date by the same change events. One batched call for the visible results costs a few milliseconds and removes most mismatches. Filtering by price range still uses the index and may be slightly stale, which is acceptable.

Step throughServing a search page with current prices
  1. Query the index for ranked resultsranking and filters, may lag
  2. Collect the SKUs on the visible page20 to 50 items
  3. Batch-fetch current prices and versionsprice service, a few ms
  4. Render results with current pricesversions travel to the cart

4 steps in order. Play them, or step through them one at a time.

6Monitoring the Lag

A 40-second lag is a minor annoyance; a lag of three hours after an indexer gets stuck is a pricing incident, with thousands of customers seeing wrong prices. We measure lag end to end, for example by comparing each event's commit timestamp with the time it is applied, and by writing a heartbeat row every minute and checking when it appears in the index. We agree a bound, such as 60 seconds at p99, and alert when it is exceeded, with a runbook that can switch the frontend to the price service for all prices if the index falls far behind.

7Follow-up questions

How would you handle a price drop: should the user get the lower price?

Yes. The checkout always charges the current authoritative price, so if it dropped the user simply pays less, and we can tell them the good news. Charging the higher price they saw would be indefensible. The asymmetry is deliberate: price rises are shown and confirmed before payment, price drops are applied automatically.

Why not have checkout read the search index so both agree?

Because then we would charge prices that can be 40 seconds or hours out of date, which can break agreements with sellers and is a much larger problem than a visible price change. The authoritative read belongs at the point where money is committed.

What if the cart and checkout themselves read from a cache?

Then the cache must be kept current by the same change events and the final charge must still verify against the database or a strongly consistent price service, with the version checked at payment time.

8Conclusion

In this answer, we saw that checkout correctly reads the authoritative price while search uses an eventually consistent copy with a 40-second lag. We keep that split but make it fair: carry a version with each displayed price, show changes clearly before payment or honour shown prices within a short window by policy, cut the lag for prices or fetch visible prices from a fast price service, and monitor the lag against an agreed bound.

What to say in the interviewAbout 80 seconds aloud

Open with

The charge must come from the authoritative database, so checkout reading it is correct; search is a derived copy fed by change data capture and is eventually consistent, so for about 40 seconds after a price rise the two disagree.

Then, if they want more

I would not make search strongly consistent, which is expensive. Instead I would make the gap visible and fair.

Each search result carries a price version, and when the item is added to the cart we compare it with the current version; if the price rose, we show the change clearly and ask the user to confirm before payment, and if it dropped, they just pay less.

If the business wants, we can honour the shown price for a short window, with a clear limit and a known cost. To shrink the problem, I would give price changes their own fast lane in the indexing pipeline, or fetch the current prices for the visible results from a quick price service and use the index only for ranking.

Finally I would monitor end-to-end indexing lag with heartbeats and alert above an agreed bound, say 60 seconds at p99, because a stuck indexer would turn this into a real pricing incident.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Which reads need which consistency here, and how would you change the design and the...": https://scrivio-interview-library.netlify.app/architecture/sd-fundamentals/62cd033eed/