Design complete systems / CHAPTER 54
Design a video service (YouTube or Netflix)
Prepare several video quality levels so the player can adjust when download speed falls, and deliver segments without making catalog or encoding work delay playback.
Builds on Design a photo-sharing service (Instagram), Design a file synchronization service (Dropbox), Batch versus stream processing, Synchronous versus asynchronous communication, Caching fundamentals.
- Recover interrupted uploads and processing without publishing incomplete video.
- Explain how a player chooses among prepared qualities and downloads short pieces.
- Calculate delivery bandwidth and enforce paid or private playback access.
01Functional requirements
A video service accepts uploads, lets viewers find videos and plays them on supported devices. A viewer’s download speed may fall when Wi-Fi weakens or mobile reception gets worse. If video data arrives too slowly, playback pauses after the player uses the video it has already downloaded.
The service prepares several video quality levels so the player can switch to one that needs fewer bits per second. It downloads short pieces, rather than the whole original file. Keep titles, access rules and saved playback positions in separate records because those small updates should not require rewriting video files.
FR1: Upload and prepare videos. Resume interrupted uploads and show processing progress. Prepare the required quality levels, playback playlists and thumbnail before publishing a playable video.
FR2: Share and play. Let viewers share a video reference, play, pause and seek on supported devices. When download speed drops or the player has little downloaded video left to play, switch to a lower quality that needs fewer bits per second.
FR3: Search the catalog. Find videos by title. Return only current metadata and thumbnails the viewer may see.
FR4: Record engagement. Define which accepted playback-start event counts as a view. Let each account choose like, dislike or neutral for each video. Display totals may update later.
FR5: Manage comments. Save comments without duplicating them on retries. Return permitted comments in pages ordered by video and time.
FR6: Resume playback. Save per-account progress with explicit rules for competing sessions and devices. Seeking backward is a valid update; the farthest position is not always the desired resume point.
FR7: Control private media. Check current permission or paid access before issuing temporary media credentials. Search and catalog results must follow the same visibility rules.
Out of scope
- Live broadcasting, advertising auctions and subscription billing.
- Recommendations and discovery products beyond title search.
Example: Mira uploads v81, “Building a raised bed.” Ben searches for it, watches session s9, comments and later resumes from his saved position.
02Nonfunctional requirements
Assume 100,000 ten-minute uploads per day, ten million 20-minute viewing sessions per day and 500,000 viewers at peak. Confirm the supported devices, network conditions and load under which the following targets apply.
NFR1: Playback startup. At least 95% of playback starts take no more than two seconds in the agreed test. A successful segment download alone does not measure time until playback starts.
NFR2: Playback continuity. Time spent stopped for rebuffering is below 1% of aggregate watched time in that test. Lower connection capacity needs lower quality; no service can guarantee uninterrupted playback on every connection.
NFR3: Playback availability. Authorization for ready videos meets 99.9% availability per calendar month. Optional counters and AI captions do not block playback.
NFR4: Durability and readiness. Saved originals and acknowledged comments survive one storage-node failure. A ready video references all required verified outputs. Accepting an upload and publishing a playable video are separate steps.
NFR5: Processing time. At planned load, at least 95% of valid ten-minute uploads finish required encoding within an assumed 30 minutes. Failed quality levels can retry. Do not publish an incomplete required set.
NFR6: Private access. Check current access before issuing media credentials scoped to the account, video and version. They expire within 60 seconds of issue. An old catalog result cannot grant fresh permission; already downloaded bytes cannot be recalled.
NFR7: Display and search delay. Target at most one minute of counter delay and 30 seconds for search and comment-list updates. Count the defined session-start event once; segment downloads, retries and bots do not by themselves prove separate human views.
NFR8: Progress conflicts. Use ordered updates within a session and a revision check across devices. Do not simply keep the maximum position, because that would discard a valid backward seek.
03Let bandwidth drive the architecture
- Original uploads: at 8 megabits/second for 600 seconds, one ten-minute video is
8 × 600 ÷ 8 = 600 MB. At 100,000 uploads/day, originals add 60 TB/day before copies and retention. Divide by eight because a byte has eight bits. - Viewing traffic: at 3 megabits/second for 1,200 seconds, one session transfers 450 MB. Ten million sessions need 4.5 PB/day. At 500,000 simultaneous viewers, aggregate playback reaches 1.5 terabits/second.
- Segment size: a player downloads short pieces called segments. Four seconds at 3 megabits/second is about 1.5 MB. Test that duration against startup delay, request count and quality-switch speed; four seconds is an example, not a universal rule.
- Prepared output storage: three quality levels at 1, 2 and 4 megabits/second for 600 seconds produce
(1+2+4) × 600 ÷ 8 = 525 MB. At 100,000/day, outputs add 52.5 TB. Together with originals, that is 112.5 TB/day before replicas, audio, thumbnails, packaging and temporary work. - Segment requests: a 1,200-second session with four-second segments makes about 300 requests. Ten million sessions make three billion/day, about 34,700/second on average. At 500,000 steady viewers, one request each four seconds means 125,000/second, before startup, seeks, retries and audio.
- Permission renewal: credentials expire in 60 seconds. Renewing every 50 seconds gives retry margin; 500,000 viewers ÷ 50 = 10,000 renewal checks/second, before starts and retries. Check access here instead of querying metadata for each segment.
Decisions
- Size upload/encoding storage separately from delivery bandwidth and segment request rate.
- Use distributed delivery caches and test how much missing content the origin can refill.
- Keep the smaller catalog, progress and credential-renewal paths separate. More catalog replicas do not provide media bandwidth.
04API Design: Requests, Responses and Retries
Begin an upload as the signed-in owner. The request key identifies this upload attempt, so repeating it after a timeout returns the same upload:
POST /video-uploads
Idempotency-Key: tour-81
{"title":"Building a raised bed","byteLength": 600000000,"visibility":"public"}
{"videoId":"v81","uploadId":"u81","partUrls":["<scoped-part-url>"],"state":"uploading"}
Finish the upload
- Send each part to its returned URL. These temporary URLs permit only the parts reserved for upload
u81. - Complete
u81. The service verifies the bytes and returns202 Acceptedwith state processing. - Check
GET /videos/v81for progress. When the required outputs are complete, it returns publishedVersion. - The same request key and content return the original upload. Changed content returns
409 Conflict; size or quota failure returns413; unsupported media returns415.
Start playback
- Ben’s player chooses request key
watch-9for one intended playback start and callsPOST /videos/v81/playback-sessionswith that key. The service checks readiness and current permission. In one database transaction, save the session, thewatch-9result and the pending accepted-start work. The key is known before sending;s9is the resulting session ID. - Success returns
{"sessionId":"s9","mediaVersion":1,"manifestPath":"/media/v81/1/master.m3u8","resumeSeconds":120,"progressRevision":3,"credentialExpiresInSeconds":60}plus a temporary credential. The credential permits delivery of this account’s allowed video version. Retryingwatch-9with the same request returnss9instead of creating or counting another session. Changed request content under that key returns409; retries still check current access, and an expired credential needs normal renewal. - If required outputs are still being prepared, return
409with code video_not_ready. The client checks video state again later; this rejected request creates neither a successful session nor a counted start. - Return
403when access is denied,404when the video is absent, or410when it has been removed.
Keep playback authorized
- Before its credential expires, session
s9callsPOST /playback-sessions/s9/credentials. - The service rechecks the account's access and returns a credential valid for at most 60 seconds for the same account, video and media version.
- Retry a failed renewal only within the remaining playback deadline, with a limit on attempts. Renewal does not create another session-start record or view count.
- Revocation blocks new credentials. A previously issued credential may remain usable until its expiry, so the design promises that stated delay rather than immediate revocation at the CDN.
Search and record user actions
GET /videos/search?q=raised%20bed&cursor=...returns a page of permitted video details and thumbnail locations.POST /videos/v81/commentsuses a request key and returns201with the saved commentId. Retrying that request returns the original comment.GETlists comments by video and time.PUT /videos/v81/reactions/mesets this account's choice to like, dislike or neutral. Repeating the choice does not add another vote.GET /me/progress/v81returns the saved position and revision, for example{"positionSeconds":120,"revision":3}. The playback-start result also supplies that revision.PUT /me/progress/v81carries sessionId, sessionSequence, positionSeconds and expectedRevision. The player increments sessionSequence for each intended update; expectedRevision is the saved progress revision it last read.- First look for a saved result for this account/session/sequence. The same update returns its original result even if the progress revision has since advanced; changed contents under that identity return
409. For a genuinely new update, check that its sequence is newer for that session and expectedRevision still matches. Save the position, next revision and update result in one transaction. A competing device’s accepted update makes the old revision conflict instead of being silently overwritten.
05Data Model and Storage Access Patterns
A rendition is one encoded quality level, such as a lower-bitrate version for a slow connection. A manifest is a playlist describing available qualities or their segment locations. A segment is a short piece of media that the player downloads and buffers.
| Record and lookup key | Purpose |
|---|---|
Video, videoId; owner/time index |
Title, owner, visibility, state, published version and duration |
Upload/job, uploadId or (videoId,version,profile) |
Expected bytes, work deadline, processing state and retries for one output profile |
Rendition, (videoId,version,profile) |
Segment/manifest locations and verified output information |
Comment, (videoId,time,commentId) |
Author, text, version and deleted state |
Reaction, (videoId,accountId) |
One current choice from which totals can be rebuilt |
Playback session, unique (accountId,startRequestKey) |
Resulting session ID, requested video/version and saved start result; one intended start survives retries |
Progress, (accountId,videoId) |
Playback position and record revision used to detect competing device updates |
Progress update, unique (accountId,sessionId,sessionSequence) |
Original update and accepted result; per-session latest sequence prevents delayed older updates |
| Search and counter views | Copied title references and delayed totals, checked against current video state when served |
A thumbnail is a separately prepared image. Do not extract a frame from the full original every time someone opens the catalog.
06Build a complete asynchronous pipeline
Start with a catalog application, a metadata database, private object storage and a background encoding program. A rendition is one prepared quality level; a segment is a short piece downloaded by the player; a manifest is the playlist naming available qualities and segment locations.
Upload and save the work
- Mira uploads video
v81through uploadu81. Split the transfer into parts so a failed part can retry without restarting successful parts. - Verify actual size and checksum. Save a processing job in the database before reporting that preparation is pending.
- An application callback alone is insufficient: a restart would forget it. A saved job lets another program resume.
Prepare and publish
- An isolated worker inspects the original and produces required quality levels, segments, manifests and a thumbnail.
- Identify tasks by video, version and profile so missing work can retry without repeating everything.
- Verify the complete required output set. The catalog database marks version 1 ready only if the video’s current version, processing state and worker attempt still match. Save pending title-search work in that same transaction. A late worker cannot restore a deleted video or publish over a replacement task. Do not expose half-prepared playback.
- Keep published objects unchanged. A later encoding gets a new version, rather than modifying segments a player already holds.
Serve the first product
- An HTTP origin serves prepared segments from storage. Indexed catalog and title-search queries find videos.
- Comments, reactions and saved playback position use separate small records.
- Encoding and segment downloads do not wait for optional counters. Later stages give encoding workers and media delivery independent capacity.
BUILD THE DESIGN, ONE CHANGE AT A TIME
Watch the architecture evolve.
Advance through the stages in this same diagram. Existing components keep their places; additions fill the available space, then add rows. Highlights show what changed from the previous stage, and numbered arrows match the connection key below.
Stage 1 of 3
Start here. A working on-demand product must distinguish accepted original bytes from a complete playable output version.
Stage 1: a complete product at one controlled origin
Follow the numbered arrows
- Creator → Catalog + processing appReserve / finalize upload
- Creator → Private media originScoped original parts
- Catalog + processing app → Catalog databaseReserve / authorize / publish ready
- Catalog + processing app → Private media originVerify / encode required outputs
- Viewer → Catalog + processing appRequest authorized playback
- Catalog + processing app → ViewerReady version + media credential
- Private media origin → ViewerControlled manifest / segment bytes
Trace the diagram in words
- The application verifies the bytes reserved by upload u81 and saves processing work.
- A worker prepares every required quality, playlist and thumbnail; the catalog checks the current processing version before marking it ready.
- Ben’s watch-9 request obtains session s9 and current permission before the origin serves versioned bytes.
- Track upload and recoverable jobs in the catalog database.
- Prepare required outputs in the application worker role, then publish one ready version.
The cost: One deployment is simple but CPU-heavy preparation can compete with catalog requests, and origin bandwidth limits repeated playback.
Why change it? An encoding backlog or a crashed high-quality task should not occupy catalog-serving capacity or force completed qualities to be encoded again.
Stage 2: profile jobs have independent capacity
Follow the numbered arrows
- Creator → Catalog / access serviceReserve / finalize upload
- Creator → Private media originScoped original parts
- Catalog / access service → Catalog databaseSaved task, permission and ready version
- Catalog database → Durable processing queueRelay sends the saved processing task
- Durable processing queue → Encoding workersWorker reads an identified quality task
- Encoding workers → Private media originRead original / write verified outputs
- Encoding workers → Catalog / access serviceReport verified profile completion
- Viewer → Catalog / access serviceRequest authorized playback
- Catalog / access service → ViewerReady version + media credential
- Private media origin → ViewerControlled manifest / segment bytes
Trace the diagram in words
- A relay reads saved job j81 and sends its identified quality tasks to the processing queue.
- Workers reuse verified medium-quality outputs while retrying the missing high-quality output.
- The catalog checks the current video/version and complete required task state before publishing; a queue acknowledgement alone is insufficient.
- Extract profile work into independent encoding workers behind a durable queue.
- A relay sends saved catalog jobs to workers; publish only after every required output is verified.
Inspect the connection changes
- Now: Catalog / access service → Catalog database: Saved task, permission and ready version
- Now: Catalog database → Durable processing queue: Relay sends the saved processing task
- Now: Durable processing queue → Encoding workers: Worker reads an identified quality task
- Now: Encoding workers → Private media origin: Read original / write verified outputs
- Now: Encoding workers → Catalog / access service: Report verified profile completion
- Previously: Catalog / access service → Catalog database: Reserve / authorize / publish ready
- Previously: Catalog / access service → Private media origin: Verify / encode required outputs
All other connections are retained. Response paths are implicit unless drawn.
The cost: Separate workers need saved attempt IDs/deadlines, duplicate-delivery checks, per-quality progress and a repair queue. Existing ready videos can keep playing while failed processing work is inspected.
Why change it? The estimate reaches 1.5 Tb/s and about 125,000 steady peak segment GETs/s; catalog scaling cannot carry those bytes.
Stage 3: independent control, preparation and byte paths
Follow the numbered arrows
- Creator → Catalog / access serviceReserve / finalize upload
- Creator → Private media originScoped original parts
- Catalog / access service → Catalog databaseSaved task, permission and ready version
- Catalog database → Durable processing queueRelay sends the saved processing task
- Durable processing queue → Encoding workersWorker reads an identified quality task
- Encoding workers → Private media originRead original / write verified outputs
- Encoding workers → Catalog / access serviceReport verified profile completion
- Viewer → Catalog / access serviceRequest authorized playback
- Catalog / access service → ViewerReady version + media credential
- Private media origin → Delivery edgeControlled origin fill on miss
- Delivery edge → ViewerVersioned manifest / segment delivery
Trace the diagram in words
- The access service checks current catalog state before giving Ben session s9 and short-lived media credentials.
- The delivery edge serves reusable segments; a missing segment is fetched from the controlled origin.
- Share one refill for simultaneous misses or keep an intermediate cache near the origin. When download speed falls, the player selects a lower prepared quality before its downloaded video runs out.
- Insert distributed edge delivery between the controlled origin and viewers.
- Keep session authorization on the unchanged catalog path; cache misses alone refill from origin.
Inspect the connection changes
- Now: Private media origin → Delivery edge: Controlled origin fill on miss
- Now: Delivery edge → Viewer: Versioned manifest / segment delivery
- Previously: Private media origin → Viewer: Controlled manifest / segment bytes
All other connections are retained. Response paths are implicit unless drawn.
The cost: Delivery caches add storage and transfer charges. They also need rules for credential expiry, removing cached media and limiting simultaneous origin fetches. The player still chooses a lower prepared quality when the viewer’s download speed falls.
07Make asynchronous preparation recoverable
Recover one failed quality level
- Job
j81requires low, medium and high qualities plus thumbnailt81. Medium finishes; the high-quality worker crashes. - Saved per-profile job rows show what is complete. Retry high under the same video/version/profile identity and verify medium for reuse.
- Publish one ready version only when every required output passes validation. A repeated queue message must not publish again.
Close the save-to-queue gap
- Save pending processing work with verified upload metadata. This pending-work record is an outbox entry.
- A relay program reads it, sends the job to the queue and records progress. If its response is lost, it sends the same job again.
- The worker checks saved job/output state before performing missing work. Each task records its current attempt ID and deadline. A replacement receives a new attempt ID; finishing an old attempt cannot mark the replacement complete. Publishing checks the current video version/state and required tasks in the same transaction. The queue remembers unfinished work, but these database checks prevent a repeated or delayed worker from publishing twice or restoring deleted media.
Give other updates their own rules
- Reactions: keep one choice per account/video. For each identified change, the counting program checks its processed-change table. If absent, save that ID and update the displayed total in one transaction; a repeated ID leaves the total unchanged. Saved choices allow a later rebuild.
- Views: save one accepted-start row under the unique pair
(sessionId,start). Add it and its count change together only if absent. A retry finds the row and adds nothing. Segment downloads are not new starts. - Progress: the player reads the current revision, numbers each intended update and retries a lost response with that same number and content. In the transaction, first return an already saved result for that account/session/number. Otherwise reject an older session number, check current permission and expected revision, then save the position, increased revision and retry result together. If another device changed revision 3 to 4, a new update expecting 3 conflicts; repeating an already accepted update returns its own result. A later valid seek 120→90 still saves 90; the position itself need not increase.
Sending these operations through a queue does not decide their meaning or automatically make external effects happen exactly once.
A verified upload creates durable work before workers publish readiness
Follow the numbered arrows
- Verified upload u81 → Saved processing taskCommit work to do
- Saved processing task → Saved processing queueRelay retries sending the same task
- Saved processing queue → Encoding workersClaim one identified quality-level task
- Encoding workers → Verified output setWrite and verify outputs
- Verified output set → Publish version 1All required outputs pass
Trace the diagram in words
- The application verifies upload u81 and saves job j81 in the database.
- A relay can send the same job more than once; the worker checks each identified quality task and its saved outputs.
- The catalog marks the version ready only after verifying every required output and confirming the processing version is still current.
08Deliver segments through an edge network
Distribute expensive work
- Add memory/CPU while one machine remains sufficient. Then add independent catalog instances and encoding workers.
- Serve unchanged media segments through a content delivery network. Missing segments fetch from a controlled origin.
- For a sudden popular segment, share a refill among simultaneous requests or use an intermediate origin cache. Otherwise cache misses can overwhelm the origin together.
Keep playback going when download speed falls
- The player reads the playlist listing available quality levels and chooses one its device can decode.
- As it downloads each segment, it measures how quickly bytes arrive and how many seconds of downloaded video remain. This saved video waiting to play is the playback buffer.
- A quality that needs 3 megabits/second cannot keep playing indefinitely over a connection delivering 1 megabit/second. Before the buffer empties, choose a lower prepared quality that fits the measured download speed, leaving room for further drops.
- Prepare matching segment times and decoding start points across quality levels. The player can then request the next segment at a lower quality without skipping or replaying part of the video.
- Shorter segments can make quality changes happen sooner, but require more requests. Test startup time, switching, request count and cache reuse. Adding catalog servers does not improve the viewer’s Wi-Fi or mobile download speed.
Scale the small records separately
- Hash
videoIdto distribute video rows; retain owner/time and title-search indexes for those different queries. - One popular video can receive many comments at once. Cap comments per response and index them by video and time; divide long histories into time ranges. Process view totals in batches only if the product accepts a delay before those totals change.
- A public title may briefly be old on a replica. Confirm the owner’s publication using a database read that includes the committed update. Check current account, audience and subscription records before issuing private or paid-media credentials; an old public title copy cannot grant access.
- Cache metadata, thumbnails and segments separately because their sizes and access rules differ.
Renew private access
- Before its 60-second media credential expires, the player asks the access service to check permission again.
- If renewal is denied, stop fetching protected bytes after the old credential expires.
- Already downloaded/buffered bytes cannot be recalled. An old public catalog response cannot issue new permission.
09Metadata, thumbnails and duplicate content
Share bytes without merging videos
- Repeated playback of
v81can reuse cached version 1 segments. - A different creator uploading identical bytes still gets a separate video record, title, audience and comments.
- A verified content hash may permit shared storage among files belonging to the same owner or an explicitly shared library, after checking access. Keep references and lifetimes separate; do not reveal another person's private upload through an existence response.
Keep catalog records small
- Prepare thumbnails as objects keyed by video/version/size. Store their locations in metadata; serve image bytes through delivery caches.
- Owner-based partitions make one owner's listing local but can overload large creators. VideoId hashing spreads rows and needs a separate owner index.
- Time ranges concentrate new uploads unless further divided.
Calculate each cost
- An 8 megabit/second original lasting 600 seconds is 600 MB: 60 TB/day for 100,000 uploads.
- A 1,200-second view at 3 megabits/second is 450 MB: 4.5 PB/day for ten million sessions.
- One hundred million 50 KB thumbnail displays add 5 TB/day.
- One million 1 KB metadata rows need 1 GB of raw cache memory.
These distinct workloads justify separate caches and indexes. A segment download should not need a new catalog database query every time.
Video bytes and catalog records scale along different paths
Follow the numbered arrows
- Owner / title indexes → Catalog servingCandidate IDs
- Catalog serving → Video metadata shardsCheck access or confirm own publication
- Video metadata shards → Metadata read replicasReplicate metadata
- Metadata read replicas → Catalog servingTolerant public fields
- Catalog serving → Thumbnail / segment edgeReturn permitted object refs
Trace the diagram in words
- Use the owner/time or title index to find possible video IDs for that specific query.
- Read the main catalog record when confirming a new publication or checking current private access.
- Return permitted thumbnail and media locations; retrieve their bytes separately from the metadata database.
10Trace upload and playback separately
- Finish the upload: verify Mira's bytes under
u81and save processing jobj81for videov81. These labels identify one upload, its work and the video, respectively. - Publish: workers verify all required segments, playlists and thumbnail
t81. Mark media version 1 ready and save work to update title search. - Discover: Ben searches “raised bed.” Search finds
v81as a possible match; the application loads current catalog details and checks permission before showing title or thumbnail. - Start playback: Ben sends request
watch-9. A permitted request saves its result, sessions9and pending start work together, then returns temporary credentials and the saved progress revision for version 1. If the reply is lost,watch-9recoverss9. His player reads the playlist and fetches segments from delivery caches. - Count the product action: process
(s9,start)once, even when retried. Store one Ben/video reaction for repeated like requests and one comment for a repeated comment request key. - Save progress: Ben reads saved progress revision 3. His session’s update 12 records 120 seconds and advances it to 4. Repeating update 12 returns that saved result. His next update, 13, can save 90 seconds after a backward seek if revision 4 is still current. Keeping only the maximum would erase his intent; another device’s intervening update instead causes a revision conflict.
- Delete: save a newer deleted-state marker, stop new media credentials, filter search/comment access and schedule media cleanup. Existing credentials retain only their short stated lifetime.
Renew the 60-second media credential after 50 seconds to leave time for a retry. Save playback position after a pause or seek, and periodically during playback—for example, every ten seconds while the network is working. That example may lose up to ten seconds of progress after a crash; failed saves require retrying the same numbered update. Do not query catalog metadata for every segment or make playback wait for optional counter updates.
11Discuss failure, observability and cost
- Encoding backlog: keep existing ready videos playable, limit incoming upload work/retries and expose processing delay or failure honestly. After a task exhausts its retries, move it to a separate inspection queue with its video, version, quality and error. Operators can repair the cause before retrying; this is often called a dead-letter queue.
- Origin failure: cached segments may still work. Missing ones need a redundant origin or an explicit playback error. An unrestricted bucket URL would bypass access checks and is not a safe fallback.
- Stale catalog: an old title does not grant permission. Check current visibility before returning protected text, thumbnails or new media credentials.
- Untrusted content: isolate parsers, validate media duration/type/size, enforce quotas and escape comment text. Retain only needed playback data.
- Measure experience: startup time, pauses while waiting for more video, delivered quality and segment errors show whether playback targets hold.
- Measure work and cost: track origin requests, processing age, counter delays and progress conflicts. Delivery, encoding, extra qualities and retained originals have separate costs.
OPTIONAL DESIGN EXTENSIONWhere AI Fits in This Design
Use: produce draft speech captions
- Input: the audio from a video version that passed upload checks, after its owner agrees to send it to the caption service.
- Output: timestamped text and confidence, saved as a separate versioned caption asset that Mira can correct.
- Integration: run beside background media preparation. Optional caption failure must not enter the two-second startup path or prevent otherwise-ready required media from publishing.
- Version and access: corrections get a new caption version without changing media segments. Current video permission also governs captions, transcripts and later transcript search. A late result cannot restore a deleted video.
- Fallback: playback continues with creator captions or an honest unavailable indication.
- Evaluation and limits: measure word/timing errors across supported languages, corrections, job age and cost per audio minute. Bound duration, retries and queue capacity. Restrict access to private audio and its transcript, set a retention period and delete both when that period ends or the source video is deleted. Treat generated caption text as display content, never as commands to catalog or encoding workers.
Amazon Transcribe gives an example of timestamped speech-to-text output. Confidence does not prove what the speaker intended.
DRAW. CALCULATE. EXPLAIN.
Publish safely and estimate the cost of a launch
75 minutes · guided practice
Video v81 has ready low- and medium-quality outputs and a thumbnail, but its required high-quality task failed. The program that forwards saved tasks to the queue crashes while resubmitting that task. Ben attempts playback before the video is ready, later opens session s9, retries its start record, repeats his like and seeks backward from 120 to 90 seconds.
- Show how saved processing work survives the forwarding crash and how the missing output is repaired.
- Trace publication, the rejected early playback and the later successful session.
- Show how repeated starts and likes avoid extra counts, while the later backward seek is accepted.
- Calculate daily upload bytes for 100,000 originals of 600 MB and thumbnail delivery for 100 million displays of 50 KB.
Compare the worked solution
- Reject playback before required outputs are ready, without creating a session-start event.
- Read saved job
j81and relay the same task again. Verify completed qualities and retry the missing high-quality output under its stable video/version/profile identity. - Publish one ready version only after all required media and thumbnail outputs pass verification.
- Check Ben’s current access and save request
watch-9, sessions9and pending start work together. Return the versioned playlist, temporary credentials and saved progress revision. A retry ofwatch-9returnss9; the counter applies the identified (s9,start) once. - Repeated like PUT requests keep one account/video choice. For progress, retry the same session sequence and content to recover its saved result; a new sequence must pass the expected-revision check. A later accepted update may save 120→90, while max(position) would erase a valid backward seek.
- 100,000 × 600 MB = 60 TB/day of originals. 100 million × 50 KB = 5 TB/day of thumbnail delivery. Keep media bytes separate from catalog, comments and progress work.
The checkboxes record your own assessment. The worked solution gives you a way to check the reasoning.
RETRIEVE BEFORE YOU REVEAL
Keep the important ideas.
Say the answer aloud, then turn the card over.
CARD 01What makes a video ready?
- Verify the original upload.
- Save resumable processing tasks.
- Prepare and verify every required quality, playlist and thumbnail.
- Publish one ready version.
An upload alone is not playable readiness.
CARD 02Which paths must be separated?
- Delivery caches/origins serve media segments.
- Catalog records find videos and check access.
- Encoding runs in background workers.
- Comments, reactions and progress have separate retry rules.
Optional counts must not block playback.
CARD 03What does deduplication or a queue not guarantee?
- Identical bytes do not merge video ownership or permission.
- Queue jobs can repeat; check saved task/output state before retrying.
- Count session starts, not segment requests.
- AI captions inherit video access and deletion rules.
CHECK THE REASONING
Can you explain the choice?
Answer every question, then finish for an immediate score and an explanation for each answer. Aim for 80%, then revisit any gaps.
CLOSE THE LOOP
Explain it without the page.
Summarise the mechanism, one trade-off, and one failure mode. Then mark this chapter complete.