Design YouTube: video upload, transcoding, and CDN
Youtube
Guided ModeCache: Hot Video Metadata at Sub-Millisecond Latency
Every playback request hits the Streaming Service which needs video metadata (manifest URL, duration, title). Without a Cache, every play hits the Metadata DB β millions of reads per second on a viral video.
Request Flow
Cache hot video metadata
The Streaming Service checks Redis for video metadata before querying the DB. A 90% cache hit rate means 90% of playback requests never touch the database.
GET video:dQw4w9WgXcQ
// hit: {manifest, title, duration, ...}
// miss β query Metadata DB β SET video:dQw4w9WgXcQ EX 3600TTL-based invalidation
Video metadata rarely changes after processing. A 1-hour TTL means the cache serves stale data for at most 1 hour. On publish/unpublish, the Metadata Service explicitly deletes the cache key (write-through invalidation).
Viral video protection
When a video goes viral, millions of requests hit the Streaming Service. Without Redis, every request queries the Metadata DB β which can't sustain millions of reads/second. Redis handles 1M+ reads/second at <1ms per instance.
Why We Need This
YouTube serves 1 billion video plays per day (~11,000 per second). Without metadata caching, the Metadata DB would need to handle 11,000 queries/second for just this data β plus all write traffic from processing. Redis makes this trivial.
Key Insight
Cache the expensive, frequently-read, rarely-changing data. Video metadata (manifest URL, title, duration) fits perfectly: read 100,000Γ/day, written once at upload. TTL + write-through invalidation keeps it fresh without DB hammering.
Step 9 of 9
