CS FundamentalsVery hardProduct-company placement
A popular product page is cached with a fixed 60-second TTL. Every minute, as the entry expires, thousands of requests miss at once and all query the database, which then times out. Which change addresses this?
- A. Lower the TTL to 10 seconds
- B. Let only one request recompute a missing key while the others wait or get the stale value (request coalescing), and add jitter to TTLs
- C. Write every update to the cache and the database in parallel
- D. Disable the cache during peak hours
Correct answer: B. Let only one request recompute a missing key while the others wait or get the stale value (request coalescing), and add jitter to TTLs
This is a cache stampede (thundering herd). Single-flight recomputation, serving stale data while refreshing early, and randomised TTLs stop many clients from hitting the database for the same key at the same moment. A shorter TTL makes it more frequent.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- According to the cone of uncertainty (Boehm, McConnell), at the initial-concept stage a project's eventual effort can differ from a…
- A team uses feature toggles. Which kind should normally be deleted soon after the feature is fully launched?
- A flight-control system uses N-version programming: three teams independently write the same module from one specification, and a voter…
- A team adds hundreds of snapshot tests that compare whole rendered pages with stored output. Six months later, which problem is most…
- A coverage-guided fuzzer runs a parser for hours with random mutations of seed inputs, and AddressSanitizer is enabled. What can it find…
- After a production outage a team draws a diagram with the problem at the head and branches for People, Process, Tools, Environment and…