Quick revision
The short answer
We stop treating a transcode as one long job. The source is split at keyframes into chunks of about 10 seconds, the chunks are encoded in parallel across many workers and joined, and the whole process is a DAG run by a workflow engine that records each task, so a failed chunk is retried alone. Short videos get their own priority lane and a fast low-resolution rendition first, workers autoscale on queue depth using cheap preemptible machines, and every task writes to a deterministic path so retries are idempotent.
What to remember
In this answer, we turned a 6-hour serial transcode into minutes of wall time by splitting the source at keyframes into chunks of about 10 seconds and encoding them in parallel. We modelled processing as a DAG in a workflow engine so each task's state is recorded and a failed chunk is retried alone. We added priority lanes and a fast low-resolution rendition so short videos go live in minutes, autoscaled on queued work using cheap preemptible machines, and made every task idempotent with deterministic output paths.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
We stop treating a transcode as one long job. The source is split at keyframes into chunks of about 10 seconds, the chunks are encoded in parallel across many workers and joined, and the whole process is a DAG run by a workflow engine that records each task, so a failed chunk is retried alone. Short videos get their own priority lane and a fast low-resolution rendition first, workers autoscale on queue depth using cheap preemptible machines, and every task writes to a deterministic path so retries are idempotent.
Why this question is asked
A single worker per upload is the first design everybody builds, and it works until uploads become varied and plentiful. Then the same design produces the symptoms in this question: a two-hour 4K film occupies a worker for six hours, a 30-second clip waits behind it, and a crash at hour five throws all the work away. Interviewers use this scenario to see whether we can turn a monolithic batch job into parallel, restartable work. In this answer, we will look at why the current design fails, split videos into chunks, model processing as a DAG, add priorities and a fast first rendition, autoscale on cheap machines, and make every task idempotent.
1Why One Worker per Upload Breaks Down
Let us look at the numbers. At 500 hours of uploads per minute, the platform receives 30,000 hours of video every hour. If encoding one hour of 4K into a full ladder takes a worker about 3 hours, keeping up needs about 90,000 busy workers at peak, and any backlog shows up as the 40,000-job queue in the question.
The single-worker design has three separate problems. Latency is tied to video length: the two-hour film takes 6 hours however many machines we own, because only one machine works on it. Ordering is first come, first served, so a 30-second clip queued behind long films waits hours for a job that needs one minute. And failure is all or nothing: if the worker dies at hour five, the job starts again from zero. Each of the following sections removes one of these problems.
2Split at Keyframes and Encode Chunks in Parallel
Video compression stores a full picture, called a keyframe, every few seconds, and the frames in between are stored as differences from earlier frames. A chunk that starts on a keyframe can therefore be decoded and encoded on its own. So the first task splits the source at keyframes into chunks of about 10 seconds. A two-hour film becomes about 720 chunks.
Each chunk is encoded independently, for each rendition, on any free worker. If one chunk takes 2 or 3 minutes to encode at all renditions, 720 workers finish the film in a few minutes of wall time instead of 6 hours. A final task joins the encoded chunks of each rendition and cuts them into delivery segments. The total compute is about the same, but it is spread across many machines at once.
There is a catch: encoders use the previous frames to decide how many bits a scene needs, so cutting into chunks can slightly change quality at chunk edges. Splitting exactly on keyframes, giving each chunk a little overlap or a two-pass rate control per chunk, and running a quality check on the joined result keep this invisible.
3Model Processing as a DAG in a Workflow Engine
Processing is not one step but many: probe, split, encode per chunk and rendition, join and package, thumbnails, a quality check, then publish. Some depend on others, and many can run side by side. That shape is a directed acyclic graph (DAG), a set of tasks with arrows saying which must finish before which.
We run the DAG in a workflow engine such as Temporal, Netflix Conductor, AWS Step Functions or Argo Workflows. The engine records the state of every task in a durable store. If a worker disappears mid-task, the engine sees the task's heartbeat stop, and after a timeout it hands just that task to another worker. Completed tasks are never repeated, so progress survives the loss of any machine, and a corrupted chunk is retried alone instead of restarting the film.
- Probeduration, codecs, keyframe positions
- Split into ~10 s chunksat keyframes
- Encode each chunk per renditionhundreds of tasks in parallel, each retried alone
- Join and packageHLS and DASH segments and manifests
- Thumbnails and quality checkrun alongside packaging
- Publishmark renditions and the video READY
6 steps in order. Play them, or step through them one at a time.
The engine keeps each task's state, so a failure repeats one box, not the whole graph.
4Priorities and a Fast First Rendition
Parallelism alone does not stop a short clip from waiting if all workers are busy with film chunks. So we schedule by priority. We keep separate queues, or weighted fair scheduling across them, by video length and creator tier: a lane for videos under five minutes, a lane for long uploads, and perhaps a reserved share for partners with launch deadlines. Workers take, say, 40 percent of their tasks from the short lane even when the long lane is full, so a clip never waits behind 40,000 jobs.
We also reorder the DAG. The first rendition to encode is a fast, low-resolution one such as 480p, using a quick encoder preset. As soon as it is packaged, the video goes live with that one rendition, and the higher renditions are added to the master manifest as they finish. A creator sees the video playable in minutes, and viewers in the first half hour simply get a smaller ladder.
5Autoscaling on Cheap, Interruptible Machines
Upload volume follows the clock, so a fixed fleet is either idle at night or overwhelmed in the evening. We autoscale workers on queue depth, or better on the estimated encoding seconds waiting, since 1,000 queued chunks of 4K are far more work than 1,000 chunks of 480p.
Encoding is batch work that can be interrupted, which makes it ideal for spot or preemptible instances, spare cloud capacity sold at a large discount (often 60 to 90 percent) that the provider may take back with a short warning. With 6-hour jobs, losing a machine meant losing hours of work. With 10-second chunks taking a couple of minutes each, a preemption costs at most a couple of minutes, because the engine reschedules that one chunk elsewhere. Small chunks are what make cheap machines safe.
6Idempotent Tasks With Deterministic Output Paths
Retries are now everywhere, so every task must be idempotent, meaning running it twice has the same effect as running it once. The way to do that is to make each task's output path depend only on its inputs: the video id, rendition, chunk number and encoding profile version. A retried encode of chunk 42 at 1080p writes to exactly the same object key and overwrites it, instead of creating chunk_0042_retry2.mp4 that the join step might pick up.
Workers should also write to a temporary key and then copy or rename to the final key only when the encode succeeded, or rely on object storage's atomic object replacement, so a crashed worker never leaves half a file at the final path. The join step reads the exact list of expected keys, so a missing or duplicate chunk is impossible to miss.
7Follow-up questions
How would per-title encoding change the bitrate ladder?
A fixed ladder gives every video the same bitrates, say 5 Mbps for 1080p. But a cartoon with flat colours looks perfect at 2 Mbps, while a grainy sports clip needs more. Per-title encoding runs quick test encodes of each video, measures quality at several bitrates with a metric such as VMAF, and picks the ladder that reaches each quality target with the fewest bits. It adds analysis compute, so it is usually worth it for popular titles, and newer approaches do the same per scene or per chunk, which fits naturally into our chunked pipeline.
Where do you store intermediate chunks, and when are they deleted?
In object storage under a work prefix keyed by video and profile version, with a lifecycle rule that deletes them a few days after the video is published. Keeping them briefly lets us re-run only the join or packaging steps if those fail, without re-encoding.
8Conclusion
In this answer, we turned a 6-hour serial transcode into minutes of wall time by splitting the source at keyframes into chunks of about 10 seconds and encoding them in parallel. We modelled processing as a DAG in a workflow engine so each task's state is recorded and a failed chunk is retried alone. We added priority lanes and a fast low-resolution rendition so short videos go live in minutes, autoscaled on queued work using cheap preemptible machines, and made every task idempotent with deterministic output paths.
Open with
The root problem is that each upload is one long serial job, so latency grows with length, short clips queue behind films and a crash throws away hours.
Then, if they want more
I would split each source at keyframes into chunks of about 10 seconds and encode chunks in parallel across many workers, then join and package them. A two-hour film becomes around 720 chunks, so six hours of serial work becomes minutes of wall time.
I would model processing as a DAG, probe, split, encode per rendition, package, thumbnails, quality check, publish, and run it in a workflow engine like Temporal or Step Functions that records each task's state. A failed chunk is retried alone and progress survives losing a worker.
For latency I would have separate queues or weights by video length and creator tier, and encode a fast low-resolution rendition first so the video goes live while higher renditions continue. Workers autoscale on queued encoding work, and because chunks are small, spot or preemptible machines are safe: a preemption costs a couple of minutes.
Finally, every task writes to a deterministic path made from video, rendition, chunk and profile version, so a retry overwrites the same object instead of leaving partial duplicates.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "How would you redesign the transcoding pipeline so short videos are ready in minutes...": https://scrivio-interview-library.netlify.app/architecture/system-design-problems/977b0dd860/