Video Streaming Platform (Netflix/YouTube-like)

Upload and ingest, transcoding pipelines, adaptive bitrate packaging, DRM, multi-CDN delivery, playback services, recommendations and the economics of bandwidth.

[!FACT] Public context Netflix runs its own CDN appliances (Open Connect) placed inside ISP networks and has written publicly about per-title encoding and its microservices on AWS. YouTube is served from Google's edge network. HLS (Apple) and MPEG-DASH are the common adaptive streaming formats; CMAF allows one set of segments for both.

[!ASSUMPTION] Scope "StreamWave", a hypothetical subscription video service (studio content) plus creator uploads, 50 M subscribers. Numbers are assumptions.

1. Business problem and objectives

Deliver high-quality video to TVs, phones and browsers worldwide with fast start, minimal buffering, and controlled bandwidth cost. Objectives:

  • Video start time p90 < 2 s; rebuffer ratio < 0.5%.
  • Support 4K HDR on capable devices; good quality at 1 Mbps on mobile networks.
  • Content protection meeting studio DRM requirements.
  • Publish creator uploads within 10 minutes for 1080p.
  • Bandwidth cost per streamed hour reduced 20% year over year.

2. Business model and revenue generation

Model Implication
Subscription tiers (resolution, screens) Entitlements and concurrent stream limits
Ad-supported tier Server-side ad insertion, ad decisioning, measurement
Transactional rental/purchase Licensing windows, regional rights
Creator revenue share View counting integrity, payouts

3. Functional requirements

  1. Ingest studio masters and creator uploads (resumable).
  2. Transcode to an encoding ladder (multiple resolutions/bitrates/codecs), audio tracks, subtitles.
  3. Package as HLS/DASH (CMAF), encrypt with DRM.
  4. Catalog, search, personalized home rows.
  5. Playback: entitlement check, license issuance, manifest delivery, CDN steering.
  6. Continue watching, profiles, parental controls, downloads for offline viewing.
  7. Live events (optional phase).
  8. Analytics: quality of experience (QoE), views, engagement.

4. Non-functional requirements

Attribute Target
Playback start p90 < 2 s
Rebuffering < 0.5% of playback time
Availability 99.99% for playback API and license service
Scale 10 M concurrent streams at peak
Bandwidth Peak egress tens of Tbps
Security Studio-grade DRM (Widevine, PlayReady, FairPlay), forensic watermarking for premium content
Regionality Geo-rights enforcement

5. Expected user base and traffic assumptions

  • 50 M subscribers, peak 10 M concurrent streams at average 5 Mbps → 50 Tbps peak egress. This dominates cost and must be served from CDN/edge caches.
  • Catalog: 20K titles × ~15 renditions × codecs; ~5 PB of encoded content including creator uploads.
  • Creator uploads: 200K hours/month; transcoding compute scales with uploads.
  • Playback API: 10 M concurrent sessions, start events ~50K/s at peak (evening prime time per timezone).

6. High-level architecture

Separate the control plane (catalog, auth, entitlements, recommendations, playback decisions) running in cloud regions from the data plane (video bytes) served by CDN/edge caches.

  1. Ingest: upload service → object storage.
  2. Processing: validation, shot detection, per-title/per-shot encoding, packaging, DRM encryption, thumbnails, subtitles → origin storage.
  3. Delivery: origin shield → multi-CDN or own edge appliances.
  4. Playback services: entitlement, manifest personalization, license proxy, CDN steering.
  5. Experience: catalog, search, recommendations, profiles.
  6. Telemetry: QoE events from players → streaming analytics.

7. Detailed component architecture

Component Design choice Reason
Upload Resumable multipart uploads to object storage with pre-signed URLs Large files, unreliable networks
Transcoding Chunk-parallel encoding on autoscaled compute (Spot/GPU where helpful), workflow orchestrated Throughput and cost
Encoding ladder Per-title (or per-shot) ladder optimization; AV1/HEVC/H.264 Better quality per bit; device compatibility
Packaging CMAF segments, HLS + DASH manifests One set of media segments for both
DRM Multi-DRM key server; CENC/CBCS encryption Studio requirements, device coverage
CDN Multi-CDN + optional ISP-embedded caches; origin shield Cost and performance; resilience
Steering Playback service picks CDN per session from real-time QoE data Route around congestion
Player ABR algorithm (buffer- and throughput-based) Adapt to network changes

8. Architecture diagram

flowchart LR
  subgraph Ingest & processing
    UP[Upload service] --> RAW[(Raw masters)]
    RAW --> WF[Encoding workflow]
    WF --> ENC[Chunk-parallel encoders<br/>autoscaled]
    ENC --> PKG[Packager CMAF<br/>HLS/DASH + DRM encrypt]
    PKG --> ORG[(Origin storage)]
    WF --> META[Catalog metadata]
  end
  subgraph Control plane
    PB[Playback API] --> ENT[Entitlements]
    PB --> STEER[CDN steering]
    PB --> LIC[DRM license service]
    HOME[Home / recommendations]
  end
  subgraph Delivery
    ORG --> SH[Origin shield]
    SH --> CDN1[CDN A]
    SH --> CDN2[CDN B]
    SH --> ISP[ISP-embedded caches]
  end
  PLAYER[Player app] --> HOME
  PLAYER --> PB
  PLAYER -->|segments| CDN1
  PLAYER -->|segments| ISP
  PLAYER -->|license| LIC
  PLAYER -->|QoE events| QOE[[QoE telemetry stream]] --> STEER

9. Frontend architecture

  • Player per platform: ExoPlayer/Media3 (Android), AVPlayer (Apple), Shaka/hls.js/dash.js (web), TV SDKs.
  • ABR: start at a conservative bitrate, ramp up based on throughput and buffer; prefetch the first segments when the user hovers/focuses a title (fast start).
  • UI built for 10-foot TV experiences (focus navigation) and mobile; artwork personalization per user.
  • Offline downloads with DRM licenses that expire.

10. Backend architecture

  • Microservices for catalog, entitlements, playback, profiles, viewing history, recommendations.
  • Playback request flow: authenticate → check entitlement and geo-rights → choose encodes based on device capabilities and plan → choose CDN → return manifest URL with signed token and license URL.
  • Viewing history writes are high volume (heartbeats every ~30 s): write to a stream, aggregate, store latest position per profile/title.

11. API design with sample endpoints

GET  /v1/home?profileId=p1&device=tv-4k          -> rows of titles with personalized artwork
GET  /v1/titles/{titleId}
POST /v1/playback-sessions   { titleId, episodeId, profileId, device: {drm: "widevine", maxRes: "2160p", codecs: ["av1","hevc"]} }
  -> { sessionId, manifestUrl: "https://cdn-b.example/v/123/master.mpd?token=...",
       licenseUrl: "https://license.example/widevine", heartbeatIntervalSec: 30 }
POST /v1/playback-sessions/{id}/heartbeats   { positionSec, bitrateKbps, rebufferMs }
POST /v1/uploads             -> { uploadId, partUrls[] }   (creator uploads)

12. Database schema and data model

Entity Key fields
Title title_id, type, metadata per locale, rights windows per country, maturity rating
Asset asset_id, title_id, encodes[{codec, resolution, bitrate, path}], audio tracks, subtitles, DRM key IDs
Entitlement account_id, plan, max_streams, resolution cap
Viewing position profile_id, title_id, position, updated_at
Playback session session_id, account, device, CDN, start time, QoE summary

Viewing positions: wide-column or key-value store keyed by (profile_id, title_id); concurrent stream limits via short-lived session leases in a fast store.

13. Database technology selection and reasoning

Data Store Reason
Catalog metadata Document store or PostgreSQL + search index Rich, versioned metadata; search
Viewing history/positions Cassandra/DynamoDB/Bigtable Huge write rate, key-based reads
Entitlements, billing Relational Money and contracts
Concurrent stream leases Redis with TTL Fast, ephemeral
Media Object storage + CDN Scale and cost
QoE analytics Kafka → Flink/Druid/ClickHouse Real-time dashboards and steering

14. Authentication and authorization

  • Account login (OIDC), device activation codes for TVs (device authorization grant), profiles with optional PINs.
  • Short-lived signed URLs/tokens for manifests and segments (CDN token auth) to deter hot-linking.
  • DRM licenses bound to device and session; output protection levels (HDCP) enforced by DRM for HD/4K.

15. Security architecture

  • Multi-DRM with key rotation; keys in an HSM-backed key service.
  • Forensic watermarking (A/B segment variants per session) for premium content to trace leaks.
  • Geo-blocking and VPN/proxy detection for rights enforcement.
  • Credential-sharing detection and account takeover protection.
  • Supply chain security for player SDKs.

16. Caching strategy

  • CDN and edge caches hold popular segments; pre-positioning popular new releases to edge caches overnight before launch.
  • Origin shield to collapse cache misses.
  • Manifests cached briefly; personalized parameters passed as tokens rather than unique manifests where possible to keep cacheability.
  • Home page rows cached per user with short TTL; artwork via image CDN.

17. Messaging and event-driven architecture

  • Encoding workflow events (UploadCompleted, EncodeCompleted, PackagingCompleted, TitlePublished).
  • Player telemetry and heartbeats to Kafka → real-time QoE, CDN steering, viewing history, recommendations training.
  • Release events trigger cache pre-positioning and notification campaigns.

18. Cloud deployment architecture

  • Control plane multi-region active-active (stateless services + replicated data).
  • Encoding farm in regions with cheapest compute (Spot capacity), close to origin storage.
  • Origin storage replicated in at least two regions; multi-CDN delivery with health-based steering.

19. CI/CD and DevOps

  • Encoding pipeline changes validated with objective quality metrics (VMAF) on a reference set before rollout.
  • Player releases staged per platform; client-side feature flags for ABR algorithm experiments.
  • Canary playback service deployments monitored with QoE metrics, not just HTTP errors.

20. Monitoring and observability

  • QoE metrics: start time, rebuffer ratio, average bitrate, playback failures, by device, ISP, CDN, region.
  • Encoding queue depth and time-to-publish.
  • CDN cache hit ratio, origin egress, per-CDN performance.

21. Scalability and performance optimization

  • Fast start: low initial bitrate, small first segments, prefetching, DNS/TLS pre-warming in the app.
  • Per-title/per-shot encoding to reduce bitrate for the same quality; modern codecs (AV1) on supported devices.
  • Chunked parallel transcoding to publish quickly.
  • Popularity-based caching tiers.

22. High availability and disaster recovery

  • Multi-CDN: if one CDN degrades, steering moves new sessions to others within seconds.
  • Control plane region failure: global load balancer routes to other regions; data replicated.
  • Encoding backlog tolerates outages (queue); published content unaffected.

23. Cost optimization

  • Bandwidth is the biggest cost: CDN contracts with commits, ISP-embedded caches at scale, codec efficiency, per-title encoding.
  • Spot instances for encoding; GPU/ASIC encoders where cost-effective.
  • Storage tiering for long-tail content; delete unused renditions.

24. Architecture trade-offs and alternatives

Decision Chosen Alternative When
CDN Multi-CDN, later own edge Single commercial CDN Small scale; simpler
Encoding Per-title ladders Fixed ladder Small catalogs or live
Packaging CMAF for HLS + DASH Separate HLS and DASH files Legacy devices needing TS segments
Build vs buy Build playback/steering, buy DRM and CDN Video platform SaaS (Mux, Brightcove, Kaltura, AWS Elemental) Faster launch, less control

25. Technology stack recommendations

Object storage (S3/GCS), FFmpeg-based encoders or AWS Elemental MediaConvert, Shaka Packager/Bento4, multi-DRM provider, multi-CDN (CloudFront/Akamai/Fastly/Cloudflare), Kafka, Flink/Druid/ClickHouse for QoE, Cassandra/DynamoDB, Java/Go services, Kubernetes, recommendation stack (feature store, two-tower models).

26. Common architecture mistakes

  1. Serving video from application servers instead of CDN.
  2. Personalizing manifests in a way that destroys CDN cacheability.
  3. Measuring success with HTTP errors instead of QoE metrics.
  4. Single CDN without steering or failover.
  5. Encoding everything at every bitrate regardless of content complexity.

27. Senior architect interview questions and answers

How do you reduce video start time?

Pre-fetch the start of likely titles, choose a low first bitrate and short first segment, keep manifest and license calls fast and parallel, reuse warm TLS connections, and pick the best CDN per session using recent QoE data.

How do you handle a new episode release watched by millions at once?

Pre-position segments in edge caches before release, ensure origin shield collapses misses, pre-scale playback and license services, and stagger notifications if needed.

How does adaptive bitrate streaming work?

Content is encoded at several bitrates and split into short segments; the manifest lists them; the player measures throughput and buffer level and requests the next segment at the best sustainable quality.

28. Enterprise architect interview questions and answers

How would you govern rights and licensing across countries?

Rights as structured data (territory, window, platforms, resolution) in a rights management system; entitlements and catalog services read it; every playback decision is checked and logged for audit with studios.

Build or buy the video platform?

Buy managed encoding/packaging/DRM to launch quickly; build differentiators (recommendations, steering, player experience) as scale grows and unit economics justify it.

29. CTO-level business and technology questions

What drives unit economics for streaming?

Content costs first, then bandwidth per streamed hour, encoding and storage, and customer acquisition. Engineering levers: codec efficiency, CDN strategy, and churn reduction via recommendations and QoE.

When would you build your own CDN?

When traffic volume makes ISP-embedded caches and peering cheaper than commercial CDN contracts and you can staff network operations, typically only at very large scale.

30. Real-world implementation roadmap

Phase Duration Outcomes
1. VOD MVP 0–4 months Managed encoding, HLS/DASH, single CDN, DRM, catalog, web/mobile players
2. TV apps and QoE 3–8 months TV players, QoE telemetry, continue watching, profiles
3. Personalization 6–12 months Recommendations, personalized artwork
4. Cost and quality 9–18 months Per-title encoding, AV1, multi-CDN steering
5. Live and ads 12–24 months Live events, ad-supported tier with SSAI