InfoWok

Design a Video Streaming Service: DRM, Live, Failure Modes and Cost (2026)

The core video design is done and the interviewer keeps going: what if the CDN dies, how do you stop piracy, what changes for live, how do you know viewers are happy, and what does it cost? A failure table, DRM basics, a premiere stampede and a cost model.

SK
Sukhveer Kaur
Published October 24, 2026
12 min read
Open in ChatGPT Open in Claude
Video streaming follow-ups: a premiere stampede is absorbed by edge and shield caches so origin sees ten requests, beside a licence flow and a live latency scale, under the line protect it, measure it, price itSoftware Architecture
VIDEO STREAMING FOLLOW-UPS
On this page +

The interviewer nods at your pipeline and says: “Good. Now your CDN has an outage at peak. And the studio wants this protected. And a premiere goes live at 8 pm.”

That is the second half of a streaming round. Drawing the pipeline is the first half. These follow-ups show whether you have thought about running it, and most answers lean on one fact from the main lesson: segments never change, so almost everything can be cached, and everything personal is small.

Advanced35 min
Before you start
Remember from the main lesson

Why can a CDN cache segments for a long time but not manifests? A segment never changes, and a manifest can. Every answer below is a version of that: keep the big, unchanging part cacheable and make the small, personal part cheap.

Key takeaways
  • A playing video survives most failures because the player already holds seconds of buffer and can try another CDN.
  • A premiere is a cache stampede. Collapse requests at each tier, and fill caches before release time.
  • DRM adds one small personal request per start, the licence, and licences cannot be cached.
  • Live trades latency for cache hits. Choose segment length by how far behind live you can be.
  • Measure start time, rebuffer ratio and failure rate by CDN, ISP and device, and set targets.
  • Egress dominates a busy day, storage dominates a long tail. Name which one your numbers show.
After this lesson you can

Answer the follow-ups that come after a streaming design: walk each failure to its fallback, absorb a premiere stampede, explain DRM and live latency, set quality targets, price the system, and handle takedowns.

What Breaks, and What Saves You#

Start with failures, because the design was built around them. “Judgement” means design opinion, not a vendor’s documented behaviour.

If this failsWhat happensWhat saves you
A segment requestPlayer retries with jittered backoffBuffered video keeps playing meanwhile. After repeated failures it switches CDN (hls.js notes)
An ISP or edge cachePlayers fail over to other URLsSteering picks caches by health. Open Connect’s control plane hands out URLs by file availability, health and proximity
Origin storageCache misses failHits still work. Add stale-if-error so caches serve stale copies on a 500 to 504
A transcode workerThe job is retriedSVE retries twice locally, then up to 6 reschedules, so a task can run 21 times
A corrupt uploadEvery retry failsSVE reports most failed jobs are corrupted uploads, so mark the video failed and tell the creator
The playback APINew starts failVideos already playing continue, since segments come from the CDN. Judgement: cache manifests briefly at the edge
The licence serverProtected starts failJudgement: several regions, and licences valid long enough to finish a session
Metadata databaseUploads and lookups stallJudgement: read-only copies and a cache for playback lookups, queue uploads
Predict first

Which row hurts a viewer who is already watching, and which only hurts people who press play now? Think about what the player already holds, then check the API and licence rows.

Which Failures Do Viewers Feel?#

A running player holds seconds of video and the manifest, so the CDN, origin and API can fail for a short time without a stall. New starts feel everything. That is why start-time and failure rate are tracked apart from stall time, as the QoE section shows. Say it plainly: a failure costs new starts first, and running sessions later.

What Happens at a Premiere?#

At 8 pm a hit title goes live. Assume 1.25 million viewers (the main lesson’s peak) press play within a minute. Every one asks for the same first segment and the same manifest. Every cache is cold for that title.

  • Works: Let the CDN sort it out. Each miss goes to origin. In the worst case that is up to 1.25 million requests for one object in one second. Trade-off: the origin falls over, and the CDN’s retries make it worse.
  • Scales: Collapse requests at each tier. Request collapsing (also called coalescing) makes a cache hold waiting requests for an object that is already being fetched and answer them all from one upstream fetch. With an assumed 1,000 edge sites, origin sees about 1,000 requests per segment per rung. With 10 shield caches in between, it sees about 10. Trade-off: waiting viewers add a little latency, and a stuck fetch can stall them all, so set a timeout.
  • Survives: Fill before release time. Netflix says it can predict what members will watch and push most content to caches in off-peak fill windows. Copy the idea (judgement for other services): finish transcoding early, keep the video in a “ready, not yet released” state, copy it to shields and edges ahead of time, and publish the manifest at release time. Origin sees nothing. Trade-off: it needs a known release time, and it fills caches for titles that may not become popular, so use it for tentpoles only.

What About Everything That Is Not a Segment?#

Segments are only one of three stampedes. The manifest can be cached for a second or two at the edge. The playback API takes about that many calls (assumed), so scale it out and rate limit with 429 and a retry-after, as in the rate limiter lesson. The licence server is the hard one, because licences cannot be shared: the next section explains why.

How Does DRM Work?#

DRM keeps a copy of a segment from being played by anyone without a key. It does not stop someone filming a screen. Studios often require it, so expect the question.

  1. Encrypt once. Segments are encrypted with a content key before they reach the CDN. They stay encrypted and fully cacheable.
  2. Ask for a licence. The player reads the key id from the manifest and sends a licence request. In browsers, Encrypted Media Extensions let the page pass that message between the decryption module and your server. EME defines no DRM itself.
  3. Check rights. A licence proxy that you run checks login, plan, region and device, then forwards the request to the DRM licence server. Widevine’s docs say its client never talks directly to the licence service, and that licences are individualised to the requesting device.
  4. Decrypt on the device. The key stays inside the device’s decryption module and the picture is shown.

Which Systems, and How Many Copies?#

SystemWhere it runsNote
WidevineAndroid, Chrome, Firefox, Edge, many TVscbcs on Android 7 and later, cenc on all listed platforms
PlayReadyMicrosoft and licensed devicesRights can include expiry, play counts and resolution limits
FairPlayApple platformsProduction use needs Apple’s approval, and goes to the party that runs the streaming service

The encryption scheme matters more than the vendor. DASH-IF says cenc and cbcs are two mutually exclusive schemes: content encrypted with one cannot be decrypted by a system that supports only the other. Encrypt one cbcs copy for current devices, and keep a cenc copy only if you still serve old Android versions (Widevine lists cbcs from Android 7). That keeps storage near one copy instead of three.

Without a studio requirement, HLS also offers simple AES-128 encryption with a key URI that must be delivered over TLS. That raises the bar for casual copying, but it is not DRM, and the key is only as safe as your token.

Licence capacity

Assume all 1.25 million premiere viewers start within 60 seconds and each needs one licence: that is about 21,000 requests a second at the licence proxy and server (1,250,000 ÷ 60). Individual licences cannot be cached, so size for that and add jittered retries and a waiting room (judgement).

What Changes for Live?#

On demand, every segment exists before anyone asks. Live creates the next segment every few seconds, and viewers sit as close to the edge as the format allows.

MethodHow far behind liveCost
HLS, 6 s segmentsat least 18 sCheap, cacheable
HLS, 2 s segmentsat least 6 s3x the requests, shorter cache life
Low-latency HLSa few seconds (judgement)Many small requests, CDN must hold blocking requests
WebRTCabout a second (judgement)Per-viewer connections, little CDN caching

The first two rows come from RFC 8216: a client should not start less than three target durations from the end of the playlist, so 3 × 6 s = 18 s and 3 × 2 s = 6 s, before encode, upload and CDN time. A live playlist must also gain a new version within 1.5 target durations, so viewers keep reloading it.

Low-latency HLS is defined in an IETF draft with three parts:

  • Partial segments, published before their parent segment is complete. The server must add a new part within one part target duration.
  • Blocking playlist reload, where the server holds a request until the part exists.
  • Preload hints, so the player can ask for a part before it is ready.

WebRTC is the other route. WHIP (RFC 9725) standardises sending media into a service over WebRTC with one HTTP exchange. For viewers it needs live connections, so use it where latency is the product, such as auctions or sports betting.

What Does Live Do to the CDN?#

Assume 1 million live viewers on 2 second segments. Each reloads the playlist about every 2 seconds, so the playlist alone draws about 500,000 requests a second, and segments add as many more (assumption). Cache playlists for a fraction of a target duration and collapse requests, or the origin sees about a million requests a second (assumed load). Shorter segments cut delay and multiply this load, so state which one the product needs.

How Do You Know Viewers Are Happy?#

Measure what the viewer feels, from the player, not from the servers.

MetricMeaningExample target (assumption)
Start timePress play to first framep95 under 2 s
Rebuffer ratioStalled time ÷ time watchingUnder 0.5%
Start failure ratePlays that never show a pictureUnder 0.5%
Average bitrate and switchesQuality delivered, and how jumpyTrack the trend

A 10 minute session with three 2 second stalls has 6 ÷ 600 = 1.0% rebuffer ratio, which would miss this target. The Netflix and Stanford buffer-based paper judged players on rebuffer rate and video rate, and Open Connect’s control plane stores playback telemetry. Players send small beacons; sample them to bound the volume.

SLOs need an error budget. A 99.95% playback API over 30 days allows 43,200 minutes × 0.0005 ≈ 21.6 minutes of failure. Slice every metric by CDN, ISP, device and region, because the useful alert is “start failures on CDN B in one ISP doubled”, not a global average. When one path degrades, steer new sessions away from it.

What Does It Cost?#

Assume these illustrative unit prices, not quotes: egress $0.01 per GB, hot storage $0.02 per GB-month, cold storage $0.004 per GB-month, compute $0.04 per core-hour. Check your own contracts. The loads are the main lesson’s assumptions.

ItemArithmeticPer month
Egress6.75 PB a day = 6,750,000 GB × $0.01 × 30≈ $2.0M
Encoding250,000 core-hours a day × $0.04 × 30≈ $0.3M
Storage, after year one, all hot192 PB = 192,000,000 GB × $0.02≈ $3.8M
Storage, 90% cold10% × $0.02 + 90% × $0.004≈ $1.1M

Three conclusions. Delivery dominates a busy day, but storage overtakes it when unwatched titles pile up, so tier cold titles and stage renditions. Assume keeping only the three lowest rungs (2.7 of 11.7 Mbit/s, 23%) for 90% of titles: that cuts bytes by about 69%. Caches inside ISPs cut egress, which is why Netflix offers them free to qualifying ISPs. Encoding is the small line, but a codec decision multiplies it.

When Does a Better Codec Pay Off?#

Assume AV1 saves 30% of delivered bits and costs 5 times the encode compute of H.264. Both are assumptions to be measured.

  • Assume encoding one hour of video into the ladder costs 2.5 core-hours × $0.04 = $0.10, so AV1 adds $0.40.
  • Assume one viewing hour is 1.5 Mbit/s × 3,600 s = 0.675 GB, which costs $0.00675 to deliver, so 30% saves about $0.002.
  • Break-even is $0.40 ÷ $0.002 ≈ 200 viewing hours per hour of video.

Popular titles pass that quickly, and the long tail never does, so make newer-codec rungs a popularity-gated stage, as the main lesson’s staged encoding does. Hardware encoders are faster and cheaper per hour but compress less well (judgement).

What About Regions and Disasters?#

Separate originals from derived data:

  • The uploaded original is the source of truth.
  • Every rendition can be rebuilt from it, at the compute cost above.
  • So replicate originals everywhere, and popular segments selectively.

Replicating all 527 TB of daily renditions is 527 × 10^12 × 8 ÷ 86,400 ≈ 49 Gbit/s. S3 Replication Time Control has a default quota of 1 Gbps, so you would need an increase or selective copying.

S3’s replication time control copies most objects in seconds and 99.9% within 15 minutes, so a title may reach region B after its manifest does. Serve manifests only for titles whose objects have arrived. Use two CDNs, and keep the playback API, metadata and licence service in at least two regions.

How Do You Fight Piracy and Handle Takedowns?#

  • Tokens. Segment URLs carry signed, short-lived tokens, so a link cannot be shared for long and hotlinking fails (judgement).
  • DRM on premium titles, as above, and per-session limits on concurrent streams.
  • Upload checks. Scan uploads for malware and policy violations in a worker before publishing, and match known works by fingerprint (judgement, no source read).
  • Takedown. US law, 17 U.S.C. section 512, conditions its safe harbour on acting expeditiously to remove or disable access after a valid notice, restoring material 10 to 14 business days after a valid counter-notice unless the claimant sues, and having a repeat-infringer policy. This is a summary of the statute, not legal advice.

Design for it: a blocked status makes the playback API refuse, manifests stop being issued, and a purge request goes to the CDNs. Segments are cached for a long time, but without a manifest and a valid token nobody can reach them.

Follow-ups Interviewers Add#

Short answers. “Judgement” marks opinion, not a vendor’s behaviour.

QuestionAnswer in one breath
Why not transcode on demand?Judgement: first viewers would wait and a hit title would encode in the stampede. Encode a base ladder up front, add costly rungs on demand.
How do you scrub or show thumbnails?Apple’s spec requires I-frame playlists for scrubbing and recommends dense ones at 1 frame per second.
How do you count views?Judgement: players send events, a stream processor counts them, and displayed counts are approximate and late.
Offline downloads?Judgement: a licence with an expiry, which PlayReady and similar systems can express, and stored encrypted segments.
Many audio and subtitle tracks?Judgement: separate renditions listed in the manifest, so players fetch only the track they need.
Cut the bill 30%?Tier cold titles, stage rungs, add ISP caches, gate newer codecs by views, as the cost section shows.
One CDN or two?Two: a spare for outages, and bargaining power. The cost is two sets of caches to warm.

A 45-Minute Plan#

text
 5 min  questions, assumptions
 5 min  numbers and API
10 min  simple design, limits
15 min  ladder, player, CDN
 5 min  failures, DRM or live
 5 min  QoE, cost, follow-ups

Pick DRM or live by what the interviewer asks. If time is short, spend the last five minutes on the failure table and offer one more topic to choose from.

Red Flags and Green Flags#

✗ Red flag

“We use a CDN, so a premiere is fine.” No cache fill, no request collapsing, and nothing about the licence server or the playback API.

✓ Green flag

“Fill the caches before release, collapse requests at edge and shield, rate limit the playback API, and size the licence service for roughly 21,000 requests a second (assumed) because licences cannot be cached.”

At staff level, expect a stated recommendation for each trade-off, a cost model with named assumptions, and an answer to “what do you build first?” (the segmented pipeline and one CDN, then QoE telemetry, then DRM).

Try It: A Premiere at 8 pm#

Exercise · Absorb the stampede15 min

A series finale premieres. Assume 1.25 million viewers start within 60 seconds, 1,000 edge sites, 10 shield caches, five rungs, and the first 2-second segment at 6 Mbit/s is 1.5 MB.

  1. How many licence requests per second does a protected title need?
  2. How many origin requests for one rung’s first segment with no collapsing, with edge collapsing, and with a shield tier?
  3. What is the cheapest way to take even that load off the origin?
Hint

Divide viewers by seconds for the licence. For origin, count how many caches must each ask upstream once.

One reasonable answer
text
Licences: 1,250,000 / 60
  ≈ 20,800 requests/s
Origin, one rung, one segment:
  none:    up to 1,250,000
  edges:   1,000
  shields: 10

Licences are individual, so they cannot be cached: size the licence path for about 21,000 a second with headroom, add jittered retries, and consider a waiting room. For the origin, collapsing takes 1.25 million down to 1,000 and a shield tier to 10 per rung and segment. Filling the caches before release time and publishing the manifest at 8 pm takes it to zero for the first segments. The counts of edges and shields are assumptions.

In an interview

After the core design, expect one of: “What if the CDN fails?”, “How do you protect the content?”, “What about live?”, “How do you know it works?”. Start with the one choice, then its cost, then a number.

Check Yourself#

Check yourself4 questions · answer, then open
1.Why can a viewer already watching often ride out a short CDN outage?

The player holds seconds of buffered video and can retry with backoff and switch to another CDN. New starts have no buffer, so they feel the outage first.

2.Why can the licence server not be protected by the CDN?

Licences are individualised to the requesting device, so one response cannot be reused for another viewer. Only the encrypted segments are cacheable.

3.Why is 6 second segment live video at least 18 seconds behind?

HLS clients should not start closer than three target durations from the end of the playlist, so 3 × 6 s = 18 s, before encode and delivery time.

4.When is an AV1 rung worth encoding?

When the title will be watched enough to repay the extra encode. Under the lesson’s assumed prices the break-even is about 200 viewing hours per hour of video, so gate it on popularity.

Learning tip

Tomorrow, cover the right-hand columns of the failure table and say what saves you for each row. Then name the one thing that cannot be cached.

In One Picture#

text
Failures
  buffer + retry + 2nd CDN
Premiere
  fill, collapse, shield
DRM
  encrypt once, licence personal
Live
  3 x segment behind live
QoE
  start, rebuffer, failures
Cost
  egress, storage, codec
Rule
  cacheable big, cheap personal

Conclusion#

The 60-second follow-up answer: a running player survives most failures on its buffer and a second CDN. A premiere is a stampede, so fill caches early and collapse requests. DRM adds a small personal licence request that cannot be cached. Live trades cache hits for latency. Measure start time, rebuffer ratio and failures by CDN and ISP, and price egress, storage and codecs with stated assumptions.

Which follow-up has caught you out before? Tell us in the comments.

Where to go from here

Frequently asked questions

How does DRM work for streaming video? +
Segments are encrypted once. The player asks a licence server for the key, the server checks the viewer's rights, and the key goes to a decryption module on the device. Widevine, PlayReady and FairPlay are the three systems, and the cbcs scheme lets one encrypted copy serve current devices.
Why is live streaming latency higher than a video call? +
HLS players are told not to start closer than three target durations from the live edge, so 6 second segments mean at least 18 seconds behind. Low-latency HLS publishes partial segments and blocks playlist requests to cut this to a few seconds, and WebRTC trades CDN caching for about a second.
What happens when millions press play on a premiere at once? +
Every cache misses the same objects at once. Request collapsing makes each edge ask upstream once, a shield tier collapses again, and filling caches before release time removes even those requests. The licence server is the next pinch point, because licences are individual and cannot be cached.
Which video quality metrics matter? +
Time to first frame, rebuffer ratio (stalled time over watch time), playback failure rate, and average bitrate. Set targets as service level objectives, and slice them by CDN, ISP, device and region so one bad path stands out.
How do you handle a copyright takedown? +
Under the US notice-and-takedown process, a provider must act expeditiously to remove or disable access to material after a valid notice, and restore it 10 to 14 business days after a valid counter-notice unless the claimant sues. In design terms, stop issuing manifests and tokens for the video and purge caches.

References

  1. Netflix, Open Connect Overview
  2. Huang et al., SVE, Distributed Video Processing at Facebook Scale (SOSP 2017)
  3. RFC 8216, HTTP Live Streaming (IETF)
  4. IETF draft, HTTP Live Streaming 2nd Edition (low-latency HLS)
  5. RFC 9725, WebRTC-HTTP Ingestion Protocol (WHIP)
  6. W3C, Encrypted Media Extensions
  7. DASH-IF Interoperability Points, Part 6 (content protection for CMAF)
  8. Google, Widevine DRM overview
  9. Apple, FairPlay Streaming
  10. Microsoft, PlayReady documentation
  11. Huang et al., A Buffer-Based Approach to Rate Adaptation (SIGCOMM 2014)
  12. Apple, HLS authoring specification for Apple devices
  13. MDN, Cache-Control header
  14. Amazon S3 User Guide, Replication Time Control (S3 RTC)
  15. 17 U.S. Code section 512, limitations on liability relating to material online
Written by
Sukhveer Kaur
Sukhveer KaurSoftware Developer & AI Engineer

Sukhveer is a software developer specialising in AI systems and backend engineering. She has hands-on experience designing agentic AI applications, working with large language model pipelines, autonomous agent frameworks, and cloud-native services in Java and Python. At InfoWok, she bridges the gap between cutting-edge AI research and practical implementation — helping developers understand and apply emerging technologies through clear, experience-backed writing.

New AI engineering guides, the day they ship

Real Python, production depth. No digest spam.

Comments