81. Design a Video Generation Service (Sora-like)
The system boundary and principal flows should make job submission, moderation, GPU scheduling, model execution, progress delivery, storage, retries, cost controls, and provenance explicit.
At a high level, I would build this as an asynchronous video job system. A client submits a prompt and settings through the API Gateway. The Job Service runs safety and policy checks, then places accepted work into a priority Job Queue. The Scheduler assigns GPU capacity while the Cost Controller enforces budgets and limits. Model Workers generate frames, report progress, and save checkpoints. Final videos and metadata go to storage, while provenance records how each output was created. The trade-off is more system complexity, but we gain safer GPU usage, retries, progress updates, and cost control.
This system lets a user request a video without waiting on one long connection. Video generation takes time and uses expensive GPU machines. We need to accept the request, check that it is safe, decide when it can run, show progress, save the result, retry when needed, control spending, and record how the video was created. The diagram solves this with a job-based flow. Each job moves through submission, moderation, queueing, scheduling, GPU execution, result delivery, storage, provenance, and monitoring.
- How should we balance shorter wait times against GPU cost?
- Which users or jobs should receive higher priority?
- How strict should moderation, retry limits, and budget limits be?
I would start by making video generation an asynchronous job. For example, a user may ask for "A cat playing piano in a snowy town." Client Apps can be web, mobile, or API clients. They submit the prompt, parameters, duration, seed, and callback information to the API Gateway. The API Gateway works with the Auth Service. The diagram shows rate limits and quotas there. These controls stop one caller from using too much shared capacity. The gateway then sends the create-job request to the Job Service.
The Job Service receives results from Input Moderation and the Policy Engine. Input Moderation checks submitted text or images. The Policy Engine applies safety and content rules. This step matters because unsafe work should be stopped before expensive generation begins. After the checks pass, the Job Service sends the accepted work to the priority Job Queue. The Job Service also publishes status events toward the progress-delivery flow.
The Job Queue holds pending jobs and gives the Scheduler controlled access to them. The Scheduler uses fair share, priority, and backpressure. Fair share helps prevent one group from taking all capacity. Backpressure means slowing new work when the system is already busy. The Cost Controller works with the Scheduler using budgets, rate limits, and preemption. Preemption means delaying or stopping lower-priority work when policy requires it. The Scheduler then sends jobs to the GPU Fleet. The Cost Controller can also scale or preempt GPU capacity.
The GPU Fleet provides the accelerator machines used by Model Workers. The diagram shows a diffusion-transformer model inside those workers. Their responsibilities are loading the model, generating frames, streaming progress, and creating checkpoints. A checkpoint is saved intermediate work from a long generation. Model Workers write checkpoints and temporary frames to Ephemeral Storage. This storage is for in-progress data rather than the final user result.
The Progress Service aggregates job status and an estimated completion time. It sends real-time updates through WebSocket or SSE. SSE means Server-Sent Events, a simple way for a server to push updates to a client. The Result Service finalizes completed outputs and manifests. Client Apps receive updates and results through this delivery area. Notification Service can send email, push, or webhook messages. The diagram also includes a Retry Service with backoff and a maximum number of attempts. Backoff means waiting before trying failed work again.
Object Storage keeps videos, frames, previews, manifests, and logs. Metadata DB keeps jobs, status, parameters, cost, and provenance information. Provenance means a record of how an output was produced. The Provenance Store records inputs, model version, parameters, seed, outputs, timestamps, and user information. It also keeps an immutable, tamper-evident audit log. Observability covers the whole system with metrics, centralized logs, end-to-end traces, alerts, and real-time dashboards. These signals help operators track latency, throughput, GPU use, cost, errors, and job health.
The main design choice is separating fast request handling from slow GPU generation. The benefit is that clients do not need to keep one request open for a long time. The downside is more services, queues, state, and failure cases. Priority scheduling and fair share improve control, but some users may wait longer. Backpressure protects the GPU Fleet when demand is high. Cost controls reduce waste, but preemption can delay lower-priority work. Checkpoints and retries improve recovery, but they use extra storage and compute. Real-time progress improves the user experience, but adds another delivery path to operate. Provenance and audit records improve traceability, but they also add storage and data-management work.
Interviewers ask this question to test whether you can design around slow, expensive, and probabilistic AI work. They want to see safe job intake, queueing, GPU scheduling, progress delivery, retries, storage, cost control, and provenance. They also test how you manage scarce resources and failures. A strong answer explains why each component exists, keeps responsibilities clear, and discusses realistic trade-offs without making unsupported guarantees.










