Design Netflix: adaptive streaming and CDN delivery
Netflix
Guided ModeEntitlement: Cache-Backed Subscription Checks
Before returning a manifest URL, the Playback Service must verify: is this user subscribed? Does their plan cover this title in their region? Hitting the database on every Play button press would collapse under load. We add a Cache (Redis) to absorb the read pressure.
Request Flow
Cache hit β fast path
The Playback Service queries Cache (Redis) with key `entitlement:{user_id}`. On a hit (>95% of the time), it gets the plan tier and licensed regions in <1ms. DRM token generation starts immediately.
Cache miss β DB fallback
On a miss, the Playback Service queries the Subscriber DB for plan details, writes the result to Cache (Redis) with TTL=60s, and continues. Cache miss adds ~5ms β still within the 15ms budget.
Cache invalidation on subscription change
When a subscriber cancels, the billing service sends a cache-invalidation event. The Cache (Redis) entry is deleted immediately so next play attempt hits the DB and gets a 403. Stale cache serving a cancelled user video is a revenue loss and a compliance issue.
Why We Need This
Netflix checks entitlement on every play. With 260 million subscribers, peak Play button presses can reach millions per minute. Without the Cache (Redis) layer, every play would hit the database, requiring an enormous read replica fleet. Cache hit rates above 95% mean <5% of plays touch the DB.
Key Insight
Entitlement is read-heavy and changes rarely. Cache it with a short TTL (60s). The only invalidation event that matters is subscription cancellation β handle it explicitly, not via TTL expiry alone.
Step 2 of 7
