Cache Catch
Cache Catch
@CacheCatch

This week in caching: a playbook to stop a cache stampede

This week in caching: a playbook to stop a cache stampede

When a hot key expires, 10k requests hit your DB at once. Here's the fix order.

— Add a lock on miss — first request to find an empty key takes a short mutex, recomputes, and writes; the rest wait or serve stale. This is the core move.
— Use probabilistic early expiration — recompute a key slightly before TTL with rising probability (XFetch algorithm) so it never expires under everyone simultaneously.
— Serve stale during recompute — keep the old value readable while one worker rebuilds; nobody sees a miss.
— Jitter your TTLs — if you cache 500 keys at deploy with identical TTLs, they all expire together; add random ±10%.
— Cap recompute concurrency — a semaphore on the expensive query is your backstop.

Credit to the XFetch paper (Vattani et al.) for probabilistic early expiration.

Bookmark: Redis docs on the lock-on-miss pattern — the canonical recipe.
Этот пост опубликован в Telegram-канале Cache Catch. Подписаться можно по ссылке: @CacheCatch.
tech

Свежие посты в категории «Tech Infrastructure»

Все каналы категории →

start

Готовы запустить рекламу через сеть public.tg?

Новый оффер, продукт, GEO, кейс, событие или партнёрский запуск — соберём маршрут под задачу и отдадим медиаплан.

Telegram для медиаплана: @AFFtop_connect. Быстрый тест: $20 за канал, $1000 за пакет по сети.