Design the backend system that powers TikTok’s short-video “For You” feed.Your design must support 1 B+ global users, 100 K+ new video uploads per hour, and 10 B+ feed requests per day with <200 ms p99 latency and 99.999 % availability. Cover (1) video upload & transcoding pipeline that converts every upload into 360 p–1080 p HLS/DASH segments and pushes them to a global CDN; (2) storage layer for multi-resolution videos, thumbnails, preview GIFs and metadata; (3) real-time recommendation service that ranks candidates from both ML-generated embeddings and collaborative-filtering models, refreshes the feed within seconds of new interactions, and solves cold-start for new users & creators; (4) feed delivery service that prefetches the next 2–3 videos while the current one plays, caches personalized pages in Redis, and gracefully falls back to trending videos when the recommender is unhealthy; (5) fan-out strategy that hybridizes push (for normal users) and pull (for celebrities) to keep read latency O(1) while avoiding the “Justin Bieber” write storm; (6) analytics pipeline that ingests likes, shares, watch-time, skips, and comments exactly once to update ML features and counters; (7) global edge caching, adaptive-bitrate streaming, resumable chunked upload, and multi-region active-active failover. Discuss APIs, data models, sharding, consistency, security, privacy, and cost trade-offs.