How to design a text-to-video service
The first sections are free. The deep dives, level expectations and quiz are part of Pro.
On this page
The problem
A text-to-video service takes a prompt and a few settings, has a model on a GPU render the clip over several minutes, and hands the user a file to watch or download. The answer turns on one figure: a minute of video holds a GPU for about 12 minutes, and there are far fewer GPUs than people waiting. That makes this a job system rather than a request system: a durable store of jobs, a scheduler that shares GPU time across users, workers that hold a lease while they render, and admission control that keeps the queue and its wait estimate honest during a burst.
Clarifying questions
| Ask | Why it matters | A typical answer |
|---|---|---|
How long does one job hold a GPU, and does a job ever span more than one GPU? | The GPU time per job decides everything downstream: whether the API can be synchronous, how fairness is measured, and how much a failed job costs to redo. | About 12 GPU minutes per minute of video on an H100, following the Factorial Funds estimate for Sora. Each job runs on one GPU; multi-GPU jobs are out of scope. |
How many users and how many GPUs are we planning for? | If GPUs outnumber waiting users, a plain queue is fine. If not, the queue and who gets served next become the heart of the design. | Thousands of users submitting prompts and far fewer GPUs than people waiting. No fleet size is given: state an assumption and work from it. |
Which settings can a user choose, and do they change the GPU cost? | Duration and resolution change how long a job holds a GPU, which is what a fair scheduler should charge for. | Duration and resolution. Assume a longer clip costs more GPU time in proportion to its length, and treat resolution as a multiplier you would measure in production. |
Do users need live progress, or is a status they can poll enough? | Jobs run for minutes, so a push channel buys little; polling keeps the API stateless. | Polling with an estimated start time is enough. A push notification when the clip is ready is a nice extra, not a requirement. |
Can a user cancel a job that is already running, and should the GPU come back right away? | Canceling a running job needs a path from the API to the worker; canceling a queued job is a row update. | Yes, queued or running, and the GPU should go back to the pool promptly rather than finishing a clip nobody wants. |
Are there paid tiers that should wait less? | Tiers turn fairness from equal shares into weighted shares, and may justify reserved capacity. | Assume a free and a paid tier. Model the paid tier as a higher weight in the scheduler and say what reserving GPUs for it would cost. |
Non-functional requirements
| Requirement | What it forces |
|---|---|
Each job runs on exactly one GPU for minutes, never split across GPUs | The scheduler matches one job to one free GPU of the right type, and a worker is busy for the whole job. No batching across requests, no sharing a GPU between jobs: throughput is the GPU count divided by the job length. |
Fair share: no single user can take the whole fleet | The scheduler keeps per-user queues and picks the next job by GPU time already used, not by arrival order, with a cap on how many jobs one user runs at once. |
Bursts far above GPU capacity queue up instead of failing | Jobs are accepted into a durable store and wait there; the API answers with a job id without waiting for any GPU work. Admission control bounds the queue per user so waiting stays meaningful rather than endless. |
A worker that dies mid-job does not send the job back to zero | Workers write checkpoints to object storage during a job, and a retry resumes from the last one. The job store, not the worker, owns the job’s state, and the death is detected by a lapsed lease. |
Estimates
| Quantity | Working | Result | What it sizes |
|---|---|---|---|
Minutes of video one GPU makes an hour | 60 minutes an hour ÷ 12 GPU minutes per minute of video = 5 | About 5 minutes of finished video per GPU per hour | Fleet throughput: multiply by the GPU count to get minutes of video an hour, the denominator of each wait estimate. |
GPU time by clip length | A 20-second clip: 20 ÷ 60 × 12 = 4 GPU minutes. A 1-minute clip: 12. A 2-minute clip: 24. Resolution adds a multiplier we would measure rather than guess | 4, 12 and 24 GPU minutes for clips of 20 seconds, 1 minute and 2 minutes | Why fairness counts GPU time, not jobs: one 2-minute clip costs as much as six 20-second clips. |
Wait behind one user’s flood under first-come first-served | Assume 100 GPUs and one user who queues 300 one-minute clips first. 300 × 12 = 3,600 GPU minutes ÷ 100 GPUs = 36 minutes. With one job per user in rotation, the next user starts when the next GPU frees, at most about 12 minutes later and usually sooner | 36 minutes before anyone else starts, against at most about 12 minutes with per-user rotation | The cost of a single shared queue, and the first thing a fair scheduler buys back. |
Backlog after an hour-long burst | Assume 100 GPUs: 100 × 5 = 500 minutes of video an hour. If users submit 1,500 minutes of video during one hour, 1,000 minutes are left over, which is 2 hours of the whole fleet’s work | A new job arriving at the end of the burst waits about 2 hours | Why admission control exists: without a bound, the wait estimate becomes hours and keeps growing while the burst lasts. |
Work lost when a worker dies near the end | A 1-minute clip without checkpoints: up to 12 GPU minutes redone, and the user waits a further 12 minutes. With a checkpoint after each tenth of the work: at most 1.2 GPU minutes redone | 12 GPU minutes lost without checkpoints, about 1.2 with ten per job | The value of checkpoints, to weigh against the time and space the writes cost. |
How fast a dead worker is noticed | Assume a heartbeat every 10 seconds and a lease of 30 seconds. A dead worker is noticed within 30 seconds, which is 30 ÷ 720 ≈ 4% of a 12-minute job | About 30 seconds of idle GPU and delay per failure | The lease length: long enough to ride out a slow heartbeat, short against the job. |
GPU time wasted by a canceled running job | With the same 10-second heartbeat, a worker reads the canceled state within about 10 seconds of the cancel | About 10 seconds of GPU time after the user clicks cancel | Why reading the job store on each heartbeat is prompt enough, with no need to reach the worker over the network. |
Storage for finished clips | Assume a 1080p clip at about 10 Mbit a second: a 1-minute clip is 600 Mbit, about 75 MB. Assume 10,000 clips a day: 10,000 × 75 MB ≈ 750 GB a day, about 270 TB a year | Roughly 750 GB a day, 270 TB a year at the assumed volume | Object storage growth and the case for a retention rule; the API servers don't hold these bytes. |
Core entities
| Entity | What it holds |
|---|---|
Job | One row per request: the prompt, the settings, where the job is in its life, and which attempt on which worker is running it. |
User | Who submits jobs: their tier, their limits, and how much GPU time they have been served. |
GPU worker | One worker for each GPU in this design: what kind of GPU it has, which job it holds, and when it last reported in. |
Video | The finished clip: which job produced it and where its bytes live. |
The API
| Endpoint | Notes |
|---|---|
| Checks the settings against the user’s quota, writes a queued job row and returns |
| In this design a status call is a read of the job row. |
| Writes the wanted state as canceled and returns |
The high-level design
Step 1 of 4
A job, not a request
The first decision is that POST /v1/videos does not wait for the clip. A request held open for the 12 minutes a one-minute clip takes would tie up a connection, break on any proxy timeout, and be lost if the API server restarted. So the API writes a job row to a durable store and answers with the id; the client polls GET /v1/videos/{job_id}. GPU workers pull queued jobs from the store, render, and write the finished clip to object storage, recording its key on the job. The store is the one place a job’s state lives, which the later steps all rely on.
What breaks first
The deep dives
Fair queueing. One user submits hundreds of clip jobs a moment before everyone else, and each job holds a GPU for minutes. Who runs next, and how do you keep the order when the scheduler restarts?
Failures in long jobs. A GPU worker dies near the end of a long clip, many minutes in. How does the system notice, what happens to the job, and what stops a slow worker that was given up on from overwriting the retry?
Cancellation and bursts. A user cancels a job just as a worker picks it up, while submissions are running far past the number of GPUs. How does the GPU get back to the pool, and what pushes back on the flood?
Concepts this guide uses
Sources
- Analytics India Mag: Sora takes about 12 minutes to generate 1 minute of video on an H100 (Factorial Funds’ estimate)
- Techovedas: How much time does OpenAI’s Sora take to generate a 1-minute video on an NVIDIA H100
- Martin Kleppmann: How to do distributed locking
- Slurm Workload Manager: Multifactor Priority Plugin