Quick revision
The short answer
A synchronous call always shows the current price and is the simplest to build, but the product page becomes as slow and as unreliable as the pricing service. A cache makes the page fast and resilient, at the cost of prices that can be stale for up to the cache's time to live. Listening to price change events and keeping a local copy makes the page fast and independent, but adds code, storage and eventual consistency. We choose by asking how stale a price may be and what latency the page must meet, and we write the choice down with its assumptions.
What to remember
In this answer, we saw that a synchronous call is fresh and simple but ties our latency and availability to the pricing service, a cache is fast and resilient but stale up to its TTL, and a local copy fed by events is fast and independent but costs more code and is eventually consistent. We choose based on how stale prices may be and the page's latency target, and we record the choice with its assumptions so it can be revisited.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
A synchronous call always shows the current price and is the simplest to build, but the product page becomes as slow and as unreliable as the pricing service. A cache makes the page fast and resilient, at the cost of prices that can be stale for up to the cache's time to live. Listening to price change events and keeping a local copy makes the page fast and independent, but adds code, storage and eventual consistency. We choose by asking how stale a price may be and what latency the page must meet, and we write the choice down with its assumptions.
Why this question is asked
Calling another service from a user-facing endpoint is one of the most common design choices in a Spring Boot system, and the slow-dependency version of it shows up in almost every design discussion. Interviewers ask it to see whether we compare options by their real costs instead of picking the most modern one. In this answer, we will set up the numbers, look at each option with code where it helps, compare them side by side, choose based on staleness and latency requirements, and see how to record the decision.
1Setting Up the Problem With Numbers
Let us make the situation concrete, because the right answer depends on it. Suppose the product page endpoint must answer within 300 milliseconds at the 95th percentile (p95, meaning 95 percent of requests are faster than that). Our own work takes about 50 milliseconds. The pricing service has a p95 of 400 milliseconds on its own, is available 99.5 percent of the time, and prices change a few times a day for most products, with flash sales changing them more often.
Notice what these numbers already tell us. The pricing service alone is slower than our whole budget, so calling it on every request cannot meet the target. And 99.5 percent availability means roughly 3.6 hours of failures a month, which our product page would inherit.
2Option 1: Calling the Pricing Service Synchronously
The simplest design calls the pricing service while handling each request, for example with Spring's RestClient. The price is always current, there is no extra storage, and anyone can understand the code.
But there is a catch: our latency and availability are now tied to the pricing service. A timeout and a fallback, such as showing 'price unavailable', soften failures but do not fix the slowness. This option fits when the price must be exact at the moment of display and the dependency is fast, which is not our case.
3Option 2: Caching the Responses
A cache keeps recent responses in memory or in Redis for a fixed time to live (TTL). With Spring's cache abstraction we can add one with an annotation, backed by Caffeine for an in-process cache.
Most requests become fast, and when the pricing service has a short outage, cached prices keep the page working. The cost is staleness: a price can be wrong for up to the TTL, five minutes here. There is also a cold-start problem, since a newly started instance has an empty cache, and the first request for an unpopular product still waits for pricing. Remember too that @Cacheable works through a Spring proxy, so the method must be called from another bean.
4Option 3: Keeping a Local Copy From Price Events
In the third design, the pricing service publishes an event, for example to a Kafka topic, whenever a price changes. Our service consumes these events and stores the latest price per product in its own table or a key-value store. The product page then reads only local data.
This is the fastest and most independent option: the page works even if the pricing service is down for hours. The price is usually only seconds behind. But we pay with more moving parts: a consumer, storage, handling of events that arrive out of order (hence the version), an initial load of all prices, and monitoring of consumer lag. This model is called eventual consistency: the local copy becomes correct shortly after a change, not at the same instant.
5Comparing the Options Side by Side
Putting the options in one table makes the trade-off visible for the design discussion.
| Option | Freshness | Page latency | If pricing is down | Cost to build |
|---|---|---|---|---|
| Synchronous call | always current | about 450 ms p95 | page shows no price | low |
| Cache, 5 min TTL | up to 5 minutes old | about 55 ms on hits | works while cached | low to medium |
| Events to local copy | seconds behind | about 55 ms always | works | high |
6Choosing and Writing It Down
The deciding questions are business ones. How stale may a displayed price be? If the business says a few minutes is fine for browsing, because the checkout re-prices the basket anyway, the cache meets the 300 millisecond target with little code, and it is usually the right first choice. If flash sales require a new price to appear within seconds, or the page must survive long pricing outages, the event-driven copy earns its extra cost. The synchronous call only wins if pricing becomes fast and freshness to the second matters on this page.
Notice that the checkout is the safety net. Even with a cached price on the product page, the final price is checked against the pricing service when the customer pays, so staleness on the page is a display issue, not a billing one.
Finally, we record the decision in a short ADR, including the assumptions: prices may be up to five minutes old on the product page, checkout re-prices, pricing p95 is 400 milliseconds, and the page target is 300 milliseconds. If any of these change, for example if the business demands real-time flash sale prices, the record tells the next person exactly which assumption broke and that the events option is the natural next step.
7Follow-up questions
Could we combine the options?
Yes, and it is common. A cache with a short TTL can be refreshed early by price change events, which evicts or updates the entry when a change arrives. That gives near-real-time prices with cache-level simplicity on the read path. It still needs an event consumer, but no full local copy or initial load.
How would you protect the synchronous option if we had to use it?
Set a strict timeout well inside the budget, for example 200 milliseconds, add a circuit breaker such as Resilience4j so we stop calling a failing service, and define a fallback like a last known price or 'price unavailable'. Those reduce the damage but cannot make a 400 millisecond dependency fit a 300 millisecond page.
What about cache stampedes when a popular entry expires?
When a hot key expires, many requests can miss at once and all call pricing. Caffeine's loading caches load a key only once per instance, and refresh-after-write lets it reload in the background while still serving the old value. With a shared cache like Redis, a lock or early refresh does the same job.
8Conclusion
In this answer, we saw that a synchronous call is fresh and simple but ties our latency and availability to the pricing service, a cache is fast and resilient but stale up to its TTL, and a local copy fed by events is fast and independent but costs more code and is eventually consistent. We choose based on how stale prices may be and the page's latency target, and we record the choice with its assumptions so it can be revisited.
Open with
I would start with the numbers: say the page needs 300 milliseconds at p95, and pricing alone takes 400. Then a synchronous call cannot meet the target, even though it is the simplest and always fresh, and it also makes our page fail whenever pricing fails.
Then, if they want more
A cache, for example Caffeine behind @Cacheable with a five-minute TTL, makes most requests fast and keeps working through short outages, but a displayed price can be up to five minutes old, and new instances start cold. The third option is to consume price change events and keep a local copy.
That is the fastest and most independent, and prices are only seconds behind, but we now own a consumer, storage, ordering by version, an initial load and lag monitoring, and the data is eventually consistent. So the real question for the business is how stale a price may be on this page.
Usually checkout re-prices the basket anyway, so a few minutes is acceptable, and I would pick the cache first. If they need flash sale prices within seconds or the page must survive long outages, I would move to events.
Whatever we choose, I would write a short ADR with the assumptions, the latency numbers and the staleness rule, so it is clear when to revisit.
About this answer
- Last updated
- 12 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 "Your team needs to call a slow pricing service from a product page endpoint. Options are...": https://scrivio-interview-library.netlify.app/architecture/architecture-decisions/a4c979b231/