Design a Video Streaming Service (with Manager)
Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2025-03-25
Problem Statement
Designing a scalable video streaming platform (like Netflix, YouTube, or Hotstar). The system should allow users to upload, store, and stream videos seamlessly with high availability and low latency.
A central Manager service should orchestrate video uploads, transcoding, metadata management, and coordinate delivery between components (e.g., CDN, storage, recommendation system).
Functional Requirements
1.Video Upload & Management
•Users can upload videos of various formats/resolutions.
•The system must transcode videos into adaptive bitrates (240p, 480p, 720p, 1080p, 4K).
•Maintain metadata (title, description, thumbnails, tags, user info).
2.Video Streaming & Playback
•Support adaptive bitrate streaming (HLS/DASH).
•Resume and buffering optimization.
•Track watch progress and history.
3.Search & Recommendation
•Search by title, tags, or categories.
•Recommendation engine based on history and trending content.
4.Manager Component
•Orchestrates uploads → triggers transcoding → updates metadata DB → registers video with CDN.
•Monitors health of streaming nodes.
•Provides APIs for scheduling jobs (upload, cleanup, caching).
5.User Management
•Authentication & authorization.
•Subscription tiers (free, premium, family plans).
6.Analytics & Monitoring
•Collect video play stats (views, watch time, retention).
•Support content creator dashboards.
Non-Functional Requirements
•Scalability: Must handle millions of concurrent viewers.
•Low Latency: Video startup delay < 2 seconds.
•Availability: 99.99% uptime with geo-redundancy.
•Cost Efficiency: Optimize storage & CDN costs.
•Security: DRM (Digital Rights Management), prevent piracy.
Design Considerations
•Manager Service
•Acts as a control plane to coordinate video ingestion, processing, and distribution.
•Can be implemented as a Job Orchestrator (e.g., with Kafka + Worker pools).
•Data Flow
•Upload → API Gateway → Storage (S3/HDFS) → Transcoding Workers → CDN.
•Metadata Service → SQL/NoSQL DB.
•Streaming handled via CDN edge servers for global distribution.
•Storage
•Raw video stored in object storage.
•Processed video segments stored in distributed blob store.
•Metadata in RDBMS/NoSQL.
•APIs
•uploadVideo(userId, file)
•getVideo(videoId, resolution)
•search(query)
•getRecommendations(userId)
•Failure Handling
•Retry failed transcoding jobs.
•Fallback to lower resolution if high-res unavailable.
•Auto-replicate data across regions.