Transcoder: big jobs, small jobs
Step 1 · The pattern
One queue, one pool of encoders
Creators upload short clips. Each joins one queue, and 4 encoders take them in turn, about 500 ms each in this picture. Uploads are ready almost at once. (All numbers are illustrative.)
- a clip
- ready
In short
Transcoder: big jobs, small jobs: how it works and how it breaks
Upload a video and the app has to transcode it: encode it into several sizes and formats so every phone and connection can play it. The work varies enormously: a 15-second clip takes seconds, a two-hour film far longer. Put every upload in one queue with one pool of workers and the averages look fine, until a few long videos arrive together. Each holds a worker for a long time, every worker is soon busy with films, and the short clips that make up most uploads wait behind them, though each would take moments. Creators see 'processing…' for an hour on a 15-second video. The usual fix is twofold: split long videos into segments and encode them in parallel across many workers, then stitch the results; and give short and long jobs separate queues and worker pools, so the common, fast case is never stuck behind the rare, slow one.
What this simulation simplifies
- Films take a fixed time here; real encode time depends on length, resolution and formats.
- Stitching segments together is folded into the long-job pool's time.
How this comes up in interviews
"Design video processing for an app where uploads range from 10 seconds to 3 hours."
Then they ask
- What happens when someone uploads 100 films at once?
- How do you show progress?
- What if an encode fails halfway?
A strong answer covers
- Separate queues and worker pools by job size or priority.
- Split long videos into segments encoded in parallel, then stitch.
- Per-customer limits so one uploader cannot take every worker.
- Progress per job; notify when ready.
- Retry failed segments, not whole videos.
Points to cover, not a script. Say them in your own words and tie them to a system you have worked on.
On one page: the track cheat sheet.
Diagrams are our own simulations: the timings, rates and counts in them are illustrative, not measurements. Captions are original wording.