- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Cache stampede: one expired key took down the database | system design interview
This is a cache stampede. The key expires, and every request that misses tries to rebuild it at the same time. 20k concurrent rebuilds of the same value, all hammering the same DB rows.
The fix, in order of effort:
1. Lock the rebuild. First request that misses takes a mutex and recomputes. The other 19,999 wait 50ms and read the fresh value. One DB query instead of 20k.
2. Serve stale while revalidating. Keep the old value past its TTL, return it while one background worker refreshes.
3. Probabilistic early refresh. Hot keys refresh themselves slightly before expiry so they never actually miss.
Production gotcha: the lock itself becomes the problem. If the rebuild takes 3s and your lock TTL is 1s, the lock expires mid-rebuild and the stampede happens anyway ❌ Size the lock TTL to your worst rebuild time, not your average.
Mutex lock or stale-while-revalidate as your default?
#systemdesign #techinterview #softwareengineering #backend #redis #caching #distributedsystems #codinginterview #faang #interviewprep
Видео Cache stampede: one expired key took down the database | system design interview канала Theberner
The fix, in order of effort:
1. Lock the rebuild. First request that misses takes a mutex and recomputes. The other 19,999 wait 50ms and read the fresh value. One DB query instead of 20k.
2. Serve stale while revalidating. Keep the old value past its TTL, return it while one background worker refreshes.
3. Probabilistic early refresh. Hot keys refresh themselves slightly before expiry so they never actually miss.
Production gotcha: the lock itself becomes the problem. If the rebuild takes 3s and your lock TTL is 1s, the lock expires mid-rebuild and the stampede happens anyway ❌ Size the lock TTL to your worst rebuild time, not your average.
Mutex lock or stale-while-revalidate as your default?
#systemdesign #techinterview #softwareengineering #backend #redis #caching #distributedsystems #codinginterview #faang #interviewprep
Видео Cache stampede: one expired key took down the database | system design interview канала Theberner
Комментарии отсутствуют
Информация о видео
13 июня 2026 г. 19:27:14
00:00:08
Другие видео канала
