Serving a sold-out homepage instantly during a flash sale
A sneaker store in Chicago crashed every drop. The homepage was uncached because "prices change," so 60,000 concurrent shoppers all hit origin at once.
We wired up stale-while-revalidate as the playbook:
— Set the homepage to max-age=10, stale-while-revalidate=300
— First request after 10s serves the slightly-stale cached page instantly, then revalidates in background
— Added stale-if-error=86400 so if origin dies, the edge keeps serving the last good copy
— Moved the live stock counter to a separate 5s-TTL fragment loaded client-side
— Load-tested the drop at 60k concurrent before going live
Next drop: origin saw roughly one request every 10 seconds for the homepage instead of 60,000 at once. Zero downtime. The trick is decoupling the volatile bit (stock count) from the cacheable shell. Test under real concurrency — SWR behaves differently at scale.
The number that mattered: 60,000 simultaneous origin hits collapsed to ~1 per 10s.
Edge of Glory
@EdgeOfGloryCDN
Serving a sold-out homepage instantly during a flash sale
Этот пост опубликован в Telegram-канале Edge of Glory. Подписаться можно по ссылке: @EdgeOfGloryCDN.