TSTier SlateAll templates
  1. Home
  2. Templates
  3. Transcoding pipeline

Video & media

Transcoding pipeline - 480 tasks, one file

Why one number, the size of a segment, sets the cost, latency and failure behaviour of the whole pipeline.

  • System design
  • core
  • 12 step walkthrough
  • 5 tables
Own this board 400 creditsPractise as an interview

The first act plays here. Owned once with credits, never a subscription.

Share

  • Facebook
  • X

What this board gets wrong on purpose

The tension

Splitting a job into 480 six-second tasks makes a failure cost 0.2 percent of the work instead of all of it, and it does that by turning one job into 480 rows of state, 480 leases and 479 joins that must not click. The job is then only as fast as its slowest task, so the p99 of a task is the p50 of a job, and one poisoned segment that fails three times holds up a stitch that 479 completed tasks are already paid for and waiting on. On top of that the whole fleet runs on spot capacity at a third of the price, which means about 5 percent of tasks an hour are killed mid-encode by the cloud provider rather than by anything in this design - a rate that is fine at six-second tasks and catastrophic at four-hour ones, so the small unit is paying for the cheap machines and the cheap machines are why the small unit was necessary.

Practise this as an interview

Take Transcoding pipeline - 480 tasks, one file as a timed system design interview on a blank board - on your own, with the requirements to check yourself against, or with a candidate you invite.

Practise this as an interview

Start here

Why this design

A transcoding pipeline is the cleanest example of a batch system whose cost, latency and failure behaviour are all set by one number: the size of the unit of work. Interviewers use it to see whether you can reason about fan-out, leases versus locks, stragglers and idempotent retries without a user in the loop to hide behind. Every video platform, every media archive and every ML preprocessing fleet runs some version of it, and almost all of them run it on preemptible machines.

What you will learn

  • Why a six second, keyframe-aligned segment turns one 8 minute job into 480 tasks, and what that buys: a failure costs 0.23 core-minutes instead of 112.
  • Why the scheduler hands out a LEASE with a 30 second heartbeat rather than a lock, and why that one choice is what makes 70 percent spot capacity usable - about $37,000 a day saved.
  • How a job is only as fast as its slowest task, so task p99 becomes job p50, and how fair share stops a 14,400 task backfill from starving a 90 second upload.
  • Why three retries then a poison queue read by a PERSON, and why every failed attempt is kept after the task finally succeeds.
  • Why the stitch is a container copy with the encoder version pinned per rendition, and why exit code 0 is not a quality check (VMAF plus a black-frame scan).
  • The hidden bill of the small unit: 16,700 state writes a second and 2.24 PB of scratch that exists only because the work was cut up.

How to read this board

  1. Diagram first, and it snakes. Along the top, left to right: SUBMIT - WHAT A JOB ACTUALLY IS (job API, ladder chooser, splitter, scratch), then STATE - ONE ROW PER SEGMENT.
  2. Back right to left through DISPATCH - WHO WAITS, AND FOR HOW LONG (task queue, the red fair-share box, the scheduler hex) into WORKERS - THE ONLY LINE ON THE BILL (CPU and GPU pools).
  3. Then along the bottom: WHEN A SEGMENT FAILS (retry policy, poison queue - note the long dashed wire back to the queue), and FINISH - STITCH, CHECK, AND THE BILL. Press play for the twelve step walkthrough.
  4. Then the pages in order: 1 · Requirements, 2 · Capacity estimation (the queue-sizing deficit is the fleet argument), 3 · Storage estimation (what a failed segment costs, in numbers), 4 · Availability, 5 · How it works, 6 · Deployment plan.
  5. Finally DATA MODEL - WHAT GENERATE SQL READS, below the pages: tasks is the table that is the architecture.
  6. The conversation to have: six seconds is the bill. Small tasks make spot capacity survivable and failures cheap, and in exchange you pay 480 rows of state per job, a straggler-bound job time, and a poisoned segment that holds 479 finished tasks hostage. Argue the segment length before anything else.

1 · Requirements

A pipeline that turns one source file into a set of renditions, on machines that can be taken away at any moment, without ever producing a file that is quietly wrong.

Functional

  • Accept a job naming a source and a target ladder, and return an id immediately.
  • Split the source into independently decodable segments and encode them in parallel.
  • Produce every rung of the ladder, in the codecs required, and stitch each one back into a single continuous rendition.
  • Retry a failed segment without redoing the job, and stop retrying when the failure is clearly not transient.
  • Report per-job progress that is honest - derived from completed tasks, not estimated from elapsed time.
  • Verify output quality before publishing: a VMAF score per rendition and a scan for black or frozen frames.
  • Account for what each job cost, in core-minutes, per rung.

Non-functional

  • Throughput: 480 million tasks a day, 5,555 a second average and three times that at peak.
  • A job of 8 minutes completes in under 10 minutes at p50 and under 45 at p99. The gap between those two is almost entirely the slowest task in each job.
  • No task is executed twice in a way that can corrupt output. At-least-once delivery plus idempotent, content-addressed writes, never exactly-once as a promise.
  • Correctness over throughput at every choice: a wrong rendition that is published is far worse than a slow one that is not.
  • The fleet runs at 70 percent or more on preemptible capacity, and losing a machine mid-task is a routine event with no operator involvement.

Questions to ask before designing this

  • What is the segment length, and who decided it? It sets the retry cost, the row count, the parallelism ceiling and the number of joins that can click. It is the single most consequential number here and it is usually inherited from a tutorial.
  • Is the ladder fixed or per-title? Per-title encoding saves 20 to 30 percent of compute and adds an analysis pass that delays every job start.
  • Are GPUs allowed? They are 20 times faster and worse at the same bitrate, so the answer differs per rung, and using them for archival masters is a decision you cannot undo without re-encoding the catalogue.
  • What is the acceptable cost of a failed job - a retry, or a phone call? That decides whether the poison queue has an automatic consumer or a human one.
  • How much does a job know about its deadline? Interactive uploads and catalogue backfills in one queue with no priority means the backfill wins by being first, which is exactly backwards.
  • Is audio segmented too? Segmenting audio on video keyframe boundaries is how you get an audible click at every join, and it is found late.

The rest of this board

Preview of the Transcoding pipeline system design board: 16 components joined by 19 connections. The labelled board opens in Tierslate.
Board preview

Available on Tier Slate

This page publishes the question. The answer — 5 more written pages, a 12-step narrated walkthrough and a 5-table schema — is the board itself, and it opens in Tierslate.

  • 5written pages
  • 12walkthrough steps
  • 5tables35 columns

5 pages behind this one

  • Capacity estimation
  • Storage estimation
  • Availability
  • How it works
  • Deployment plan
Open this board in TierslateBrowse every board

Related system design templates

Upload, transcode, deliver - and pay for the bandwidth. 8 more video & media templates:

  • Image CDN system design - Why the cache key is the design, and why egress and the long tail of misses set the bill, not CPU.
  • Live streaming system design - Why segment length sets latency, resilience and cost at once, and what each second removed costs.
  • Streaming playback system design - Why streaming is a bandwidth problem, solved by placing the bytes inside the network before anyone asks.
  • Video upload system design - Why a durable receipt for a 500 MB upload and a video that plays everywhere are two separate promises.
  • File upload system design - How presigned URLs send uploads straight to object storage, and what the server still has to check afterwards.
  • Music streaming system design - Why audio is small enough to prefetch, and why play counts and royalties are the hard ledger underneath.
  • Short video feed system design - Why a short-video feed is ranking plus prefetch, and why the first second of video decides retention and cost.
  • Video calls system design - Why a group call forwards streams through an SFU, and how bandwidth estimation keeps a bad link from ruining the call.
Open the Transcoding pipeline board in TierslateAll video & media templatesAll 100 system design templates
Tierslate

tierslate.com

HomeTemplatesGuidesCompareAboutUI mockupsPrivacyTerms