Skip to content

System Design · Worked case study

Designing an On-Demand Video Platform

Design a secure upload-to-playback pipeline with resumable checksummed ingestion, retryable transcoding, versioned manifests, DRM boundaries, and CDN-aware quality measurement.

Written for readers who already know the basics. If the words here are new to you, read The request lifecycle and Capacity estimation first.

Original educational architecture · Version 2026-11-12.1 · Examples use stated hypothetical assumptions, not a company's actual design.

What you will be able to explain

  • Estimate upload, transcode, storage, and playback traffic with explicit unit conversions.
  • Make uploads and transcode jobs resumable, checksummed, idempotent, and observable.
  • Explain manifest, DRM, CDN, entitlement, and regional failure boundaries without overstating protection.

Set the media lifecycle and promise

Design a subscription video service for educational and documentary programs. Creators upload a master file; the platform validates it, scans metadata, transcodes a defined adaptive-bitrate ladder, packages segments and manifests, stores outputs, and serves entitled viewers through a CDN. Assume 2 million monthly viewers, 200,000 daily viewers, 40,000 concurrent streams at a major event, and 100,000 titles. Exclude live broadcast, user-generated comments, editing tools, social sharing, and a guarantee that every title has identical regional availability. Playback should start quickly on a supported device, adapt to changing bandwidth, and recover from a temporary CDN or network interruption. Uploads can take hours and clients may disconnect; the service must resume parts instead of restarting the whole file. Content rights, subscription entitlement, and device compatibility are explicit inputs. A manifest is not a license to watch: the playback API verifies entitlement and issues bounded access. DRM deters casual copying on supported devices but cannot prevent screen recording or protect plaintext after a compromised player has access. Define retention for original masters and generated renditions, plus the cleanup process after a rights takedown. This is a hypothetical design, not an account of any specific streaming company's internal architecture.

Estimate bytes, compute, and concurrent delivery

Assume 100,000 catalog titles, each with a 10 GiB source master on average: raw masters total about 1,000,000 GiB, or roughly 977 TiB. If an average title has six encoded variants and total rendition size averages 2.5× the source, encoded outputs occupy about 2.4 PiB before replicas, packaging overhead, and lifecycle versions. Avoid treating every variant as an identical copy; measure actual duration and codec compression. For playback, 40,000 concurrent viewers at an average delivered rate of 3 Mb/s require 120,000 Mb/s, or 120 Gb/s of aggregate egress. A single CDN origin should not serve this load; cache hit ratio and regional distribution dominate cost. If 20,000 creators each upload one 10 GiB master per month, ingest is 200,000 GiB/month, about 6.7 TiB/day averaged, while launches may create a burst of 500 concurrent uploads. Multipart parts of 64 MiB yield roughly 160 parts per 10 GiB file; at 500 simultaneous uploads, part tracking and checksum validation matter. If transcode work takes 2× source duration in compute time and daily incoming duration is 50,000 hours, the pipeline needs about 100,000 compute-hours/day, or 4,167 continuously busy worker equivalents before headroom. Reserve 30% compute and storage headroom, isolate upload and transcode quotas, and budget CDN egress from actual viewing hours and bitrate mix.

WorkloadCalculationImplication
Master storage100,000 × 10 GiB ≈ 977 TiBObject storage and lifecycle policy are central
Concurrent egress40,000 × 3 Mb/s = 120 Gb/sCDN capacity and cache locality required
Multipart parts10 GiB / 64 MiB ≈ 160 parts/fileRetry and integrity state per part
Transcode compute50,000 h/day × 2 = 100,000 worker-hours/dayAbout 4,167 continuous worker equivalents before headroom

Start with a bounded monolith and split heavy media work

A small first release can use one creator API, a relational catalog, object storage for masters and outputs, and a background worker for a narrow encoding profile. A monolith coordinates metadata and entitlement while storage handles large bytes. Do not stream multi-gigabyte uploads through web application memory. The initial worker becomes a bottleneck when codecs have different hardware needs, jobs last hours, retries multiply compute, and viewers compete with ingestion for network. Evolve toward a control plane for catalog, upload sessions, rights, and playback authorization; an object-store data plane for masters and renditions; a durable job queue; specialized transcode pools; a packager; and CDN origins. The control plane stores workflow state and emits versioned jobs. Workers are disposable and idempotent, writing outputs to unique versioned paths; a completion record promotes a whole rendition set only after validation. The playback API returns a signed manifest location and, when supported, a DRM license route. Keep raw media and public catalog metadata in different access domains. Multi-region delivery can replicate packaged content to origin storage close to viewers, while a single authoritative rights service controls whether new playback sessions are granted. A global CDN does not make entitlement checks globally consistent by itself.

Upload control plane and playback data plane
1. Creator client

Resumable upload and status polling

2. Media control API

Upload sessions, rights, catalog and workflow state

3. Private source object store

Multipart master objects and checksums

4. Durable job queue

Transcode, validate, package and replicate work

5. Transcode and packager pools

Retryable rendition jobs and manifests

6. Protected media origin

Versioned segments, manifests and subtitles

7. Playback API

Entitlement and short-lived playback authorization

8. CDN

Cached segments near viewers

9. Viewer player

ABR selection and DRM-compatible playback

  1. Creator client → Media control API: create upload session
  2. Creator client → Private source object store: multipart parts
  3. Private source object store → Media control API: complete + checksum
  4. Media control API → Durable job queue: durable workflow event
  5. Durable job queue → Transcode and packager pools: at-least-once jobs
  6. Transcode and packager pools → Protected media origin: validated versioned output
  7. Viewer player → Playback API: entitlement request
  8. Playback API → Viewer player: manifest/license authorization
  9. Viewer player → CDN: segment requests
  10. CDN → Protected media origin: cache miss

Make large uploads resumable and verifiable

POST /v1/uploads creates an upload session with creator, declared size, checksum algorithm, media policy, expiration, and a unique upload ID. The server chooses a part size and returns bounded signed URLs for parts; credentials must not grant access to unrelated objects. The client uploads each part independently, recording part number, ETag or provider checksum, and byte range. Retrying a part replaces the same numbered part rather than appending duplicate bytes. POST /v1/uploads/{id}/complete sends an ordered part list and whole-object checksum. The service verifies ownership, size, part continuity, and checksum before atomically marking the source object received. A disconnect resumes by listing already accepted parts. If the final checksum differs, quarantine the object and require re-upload of corrupt parts or the full file according to storage capability. Never trust a client-declared MIME type; inspect file signatures, duration, codec, and malware policy in an isolated parser. Enforce maximum size, duration, account quota, and concurrent upload limits. Store UploadSession(uploadId, ownerId, objectKey, expectedBytes, checksum, state, expiresAt, version) and UploadPart(uploadId, partNumber, bytes, checksum, providerTag). An abort worker removes incomplete parts after a safe retention period and audits cleanup. The browser receives short-lived part grants, not broad bucket credentials.

http · Illustrative example; validate before production use

POST /v1/uploads/u_71/complete
Authorization: Bearer <session>

{"parts":[{"number":1,"checksum":"sha256:...","tag":"p1"},{"number":2,"checksum":"sha256:...","tag":"p2"}],"wholeChecksum":"sha256:...","byteLength":10737418240}

202 {"uploadId":"u_71","state":"validating","statusUrl":"/v1/uploads/u_71"}

Orchestrate retries, renditions, and manifests

After source validation, create a workflow version containing the source checksum, requested codec ladder, subtitle policy, audio tracks, packaging format, and rights region. Split work into probe, transcode each rendition, validate output, package segments, generate manifests, replicate, and publish. Each job has a deterministic idempotency key derived from upload ID, source version, profile, and step. A worker writes to a staging path and commits a completion record only after decoding samples, checking duration and segment continuity, and verifying checksums. A retry can reuse a validated immutable output; it must not overwrite an active rendition in place. Permanent codec errors go to a dead-letter state with a creator-visible explanation; transient capacity errors retry with exponential backoff and jitter. A job lease has a fencing generation so a worker that lost ownership cannot promote stale outputs after its lease expires. A manifest references only completed segments and compatible codecs. Publish by atomically switching a catalog pointer to a validated package version, then purge or version caches appropriately. Keep the prior package during rollout for rollback, subject to rights and storage policy. Track workflow state per rendition so one failed low-resolution variant need not always block every usable format, but the product explicitly decides whether partial publication is allowed.

Versioned media processing state machine
1. Received

Parts complete and whole-object checksum verified

2. Probe and scan

Container, codecs, duration and safety policy

3. Transcode ladder

Independent idempotent rendition jobs

4. Validate outputs

Decode samples, checksum and duration checks

5. Package

Segments, manifests, captions and DRM metadata

6. Replicate

Target origin regions and verify objects

7. Published version

Catalog pointer atomically selects usable package

8. Quarantined / retry

Classified failure with audit and operator action

  1. Received → Probe and scan: durable workflow
  2. Probe and scan → Transcode ladder: valid source profile
  3. Transcode ladder → Validate outputs: rendition output
  4. Validate outputs → Package: verified variants
  5. Package → Replicate: complete package
  6. Replicate → Published version: origin checks pass
  7. Probe and scan → Quarantined / retry: permanent invalid input
  8. Transcode ladder → Quarantined / retry: retry budget exhausted

Authorize playback and design delivery

POST /v1/playback-sessions checks the viewer's session, subscription, title rights, region, account status, device limits, and parental policy. It returns a short-lived playback token, manifest URL, supported DRM license endpoint, and expiration. The manifest contains versioned segment URLs or a tokenized path; each request is authorized by a scoped CDN token or signed cookie. Do not make a publicly cacheable manifest reveal a private title to an unauthorized client. Segment objects can be cached broadly only when the token and CDN policy enforce access, or when the content is legitimately public. Cache keys must not accidentally omit region, codec, language, or authorization dimensions. A player requests a low initial bitrate, measures buffer health and throughput, and switches renditions at segment boundaries. HLS or DASH manifests list renditions and segments; the player handles adaptation. DRM license service verifies playback entitlement and device-specific challenge, but DRM is not a substitute for entitlement authorization or a guarantee against capture. For rights revocation, short token lifetimes, cache purge, and denial of new licenses bound exposure. Playback telemetry should include startup time, rebuffer events, rendition switches, errors, and CDN region, but not raw viewing history in unbounded logs. Measure quality by device and network so a global average cannot hide a poor experience.

  • Separate manifest authorization, segment delivery, and DRM licensing as distinct controls.
  • Token expiry should bound stale entitlements without forcing excessive license calls.

Preserve integrity across retries and publication

The source checksum establishes the identity of uploaded bytes; per-part checksums detect transfer corruption early, while a whole-file checksum confirms assembly. The client-provided checksum is a claim that must be validated by storage or a trusted worker. A transcode job can be delivered more than once, so a job key and immutable output path make retries safe. A worker may crash after writing media but before recording completion; the next worker checks checksum and validation metadata before reuse. A worker lease generation prevents an old process from switching the active catalog pointer. The publication transaction updates package version and workflow status atomically in the catalog; object storage is outside that transaction, so publish only after every required object is verified. For regional replication, record expected object version and checksum and verify at destination before advertising the region. Deleting a title creates a rights tombstone and prevents new playback sessions immediately, while background object cleanup follows retention and legal rules. Existing sessions and CDN tokens have bounded lifetimes. Avoid mutable object names because CDN caches and players may mix versions. Reprocessing with a new codec ladder creates a new package version and allows staged rollback. Test corruption, duplicate completion, part replay, worker lease loss, partial replication, and a manifest referencing a missing segment.

  • Treat immutable output paths plus checksums as the boundary between safe retry and accidental overwrite.
  • A published manifest must refer only to verified, available segments.

Recover from storage, worker, and regional failure

If upload storage is unavailable, keep the session resumable and do not mark it complete from client state. If the source object exists but the callback was lost, reconcile the object checksum against the upload session before creating jobs. If transcode capacity is exhausted, queue work with tenant fairness and expose processing status; do not retry permanent malformed input indefinitely. If a rendition fails, publish only a supported partial ladder when product policy permits and player compatibility tests pass. If an origin or CDN region fails, route to another verified replica; the manifest must not point at an unreplicated object. During regional control-plane loss, previously issued short-lived playback tokens may continue until expiry, but new sessions fail according to policy. For emergency rights revocation, deny new sessions and licenses, invalidate tokens where supported, purge CDN caches, and monitor residual requests. A recovery exercise should restore catalog workflow state and verify its object references, not only bring databases online. Cross-region replication may lag, so distinguish source upload durability from availability of each rendition region. Avoid active-active writes to the same workflow without fencing; one workflow owner controls package promotion. Backups must include signing-key rotation procedures and DRM integration configuration without storing secret keys in ordinary application backups.

FailureSafe behaviorRecovery verification
Part upload interruptionResume known part list; retry missing partsWhole checksum matches before validation
Worker crashRetry deterministic job; reject stale lease generationOutput checksum and state agree
CDN region lossServe verified replica or fail clearlyManifest references reachable package
Rights emergencyDeny new sessions/licenses and purge cachesSampled access denied across regions

Protect content, creators, and viewing data

Use separate roles for creator upload, catalog publication, operations, and playback. Upload grants are scoped to one object and expire quickly; all source masters and unpublished outputs remain private. Inspect files in isolated, resource-limited workers because parsers process attacker-controlled containers and codecs. Validate metadata, sanitize filenames, enforce quotas, and prevent decompression bombs or extreme-duration inputs. Signed URLs and CDN tokens are bearer capabilities: keep them short-lived, avoid referrer leakage, scope paths and methods, and do not log them. DRM keys and signing keys belong in managed key services with rotation, auditing, and strict access separation. A license endpoint should disclose only the minimum title and device metadata needed. Protect viewing history as sensitive behavioral data with retention controls, consent, and restricted staff access. Do not promise DRM makes content impossible to copy; supported client platforms vary and users can record playback externally. Rights windows, geographic restrictions, subtitles, and accessibility assets need their own policy checks. Audit manual publication and takedown actions. Security tests should attempt cross-account upload completion, altered part lists, stale playback token use, region-rule bypass, origin access without CDN authorization, manifest leakage, and malicious media parsing.

  • Keep source objects and staging outputs private even if final segments are cacheable under a scoped token.
  • Separate key management and entitlement from ordinary catalog administration.

Measure upload health and playback quality

Upload success should measure valid sessions that complete checksum validation, separated by file size and client network. A target might be 99.5% successful completion for eligible uploads, with resume success after interruption above 99%. Transcode freshness measures complete workflow time from verified source to published package; define distinct targets by duration and profile, such as p95 under four hours for a two-hour master. Playback SLOs include startup time, fatal playback error rate, rebuffer ratio, and successful license acquisition. Example goals could be p95 startup below 3 seconds on broadband, rebuffering below 0.5% of viewing time, and 99.9% successful authorized playback sessions. These are hypotheses to validate by device and geography. Track checksum mismatch, retry count, queue age, worker utilization, rendition failure, missing segment fetch, CDN cache hit ratio, origin egress, license latency, token denial, and regional replication lag. Segmenting by device model and codec reveals incompatibility masked by averages. Use privacy-safe aggregated telemetry and bounded retention. Test playback from each region and upload an intentionally corrupted part. Alerts should distinguish an overall CDN issue from a single codec profile failure; rollback a bad package version without removing the last known-good version.

IndicatorBoundaryInitial target
Upload completionSession created to validated source99.5% eligible sessions; resume success > 99%
Transcode freshnessVerified source to published packagep95 < 4 h for defined 2 h profile
Playback startupPlay request to first rendered framep95 < 3 s on broadband
Rebuffer ratioRebuffer time / viewing time< 0.5% for supported cohorts

Model cost and migrate through package versions

A hypothetical monthly bill might include $45,000 for object storage of masters and renditions, $35,000 for CDN delivery at 40,000 concurrent viewers with variable hours and regional rates, $25,000 for transcode compute, $8,000 for control-plane databases and queues, $10,000 for monitoring, origin requests, and recovery replicas: about $123,000 before DRM licensing, content rights, taxes, and staff. CDN egress and retention dominate; the estimate can vary by several times with viewing hours, average bitrate, cache hit, codec efficiency, and geography. A third-party encoding service can reduce worker operations but create per-minute cost and vendor dependency. A limited codec ladder reduces storage but may worsen quality on constrained networks. Start with one validated ladder and measure device coverage. Migration to new codecs uses immutable package versions: transcode in parallel, validate sample devices, publish to a small cohort, compare startup/rebuffer/error metrics, then expand. Rollback switches catalog pointers; old segments remain until active tokens and cache lifetimes expire. Do not delete masters until retention and reprocessing policy allows it. Interview follow-ups include live streaming, low-latency protocols, subtitle alignment, ad insertion, offline downloads, DRM device limits, and cost optimization through newer codecs.

  • Track cost per viewing hour, per uploaded source hour, and per retained title.
  • Treat CDN cache hit ratio as a cost and origin-capacity metric, not as the only quality metric.

Terms in plain language

Multipart upload
A transfer that uploads an object as independently retryable parts and assembles them after validation.
ABR ladder
A set of encoded variants at different bitrates and resolutions that lets a player adapt to bandwidth.
Manifest
A playlist or index describing media segments and available renditions for a player.
DRM license
A time-limited authorization and key response that a compatible player uses to decrypt protected media.

Capacity lab

Change the assumptions and inspect the math. This teaching model assumes every request creates one stored record. Real systems separate reads, writes, uploads and background work.

Average QPS
231.48
daily users × requests per user / 86,400
Peak QPS
1,157.41
average QPS × peak multiplier
Peak payload bandwidth (MB/s)
1.16
peak QPS × bytes/request / 1,000,000
Logical retained storage (GB)
600
requests/day × bytes/request × retention / 1,000,000,000
Replicated storage (GB)
1,800
logical storage × stored copies
Serving nodes
1
ceil(peak QPS / (node throughput × utilization))

Decimal MB/GB, not MiB/GiB. Indexes, protocol overhead, compression, retries, backups and failover capacity are excluded. Measure throughput on your workload; this is not a sizing guarantee or a cloud price quote.

Preparing practice controls…

Check your understanding

These checks explain concepts. They do not measure architecture seniority or update readiness.

1. A transcode worker crashes after writing segments but before recording success. What makes retry safe?
2. What does DRM guarantee?

Design independently

A creator's 18 GiB master upload reports complete, but the whole-object checksum does not match. An automated retry later produces a valid source. One 1080p transcode worker crashes after uploading segments but before recording completion; a stale worker then attempts to publish a manifest while a new version is being processed. Explain the upload and workflow state transitions, fencing and idempotency rules, storage cleanup, publication guard, and creator-facing status. Then describe how a regional CDN failure and urgent rights takedown affect playback tokens, manifests, licenses, and cached segments. Include SLOs and a safe codec migration plan.

Hints, not a solution
  • A client completion callback is not proof of byte integrity.
  • Use immutable versioned outputs and validate before switching the catalog pointer.
  • Distinguish ongoing playback from new authorization and license issuance.

0 / 20,000 characters · Not saved

Your learning notes

Sign in to save

Marking a lesson read and reviewing an exercise are separate actions. Neither implies mastery. Saved work is account-owned; saves are explicit and do not queue offline.

References and boundaries

Primary documentation supports the mechanisms described. It does not certify these hypothetical architectures, prices or sizing assumptions. Review platform-specific behavior before implementation.

RFC 8216: HTTP Live Streaming

Defines the HLS playlist and media format; it does not establish this service's upload, entitlement, or DRM policy.

Amazon S3: Multipart upload overview

Documents one object store's multipart upload mechanics, not the hypothetical workflow or provider-independent guarantees.

Widevine DRM overview

Explains a DRM system and its ecosystem; it does not verify that DRM prevents all capture or copying.

Back to curriculum