Ctrl K
Backend · Mid-level · Theory

You have a popular key in Redis with a TTL, and every time it expires, the database gets a load spike and starts to slow down. What's going on, and how do you fix it?

~4 min by voice

How to approach it

The interviewer wants to see whether you recognize a cache stampede (dogpile, thundering herd) and understand its mechanism. The second thing that matters: whether you can propose several layers of protection rather than just "increase the TTL" or "give the database more resources".

Have you seen this question in a real interview?
Answers0
Avg. score—
Strong—
Practiced0
Topics
Similar questionsПеред базой стоит кеш в Redis с карточками товаров, TTL — пять минут. Расскажите, как бы вы организовали чтение и обновление, как кеш может разойтись с базой, и что произойдёт, когда истечёт TTL у очень популярного ключа. Mid-levelWrite a memoizeAsync function. It takes an async function of a string key and a cache time to live in milliseconds, and returns a wrapper: a repeated call with the same key doesn't go to the network, concurrent calls share a single request, and errors aren't cached. SeniorYou added a cache in front of the database for product cards, and users started complaining that they see outdated prices. How should you set up caching to avoid this? Mid-levelDesign a URL shortener: a user submits a long URL and gets a short one, and following the short link redirects to the original. Mid-levelWhy does a backend need a cache, and what problems show up when you add one? Junior

Answer by voice

The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.

Sign in to answer

Best with headphones · ~4 min