hard

Design DALL-E

Design a multi-tier image generation service where users submit a text prompt plus parameters (resolution, style, tier) and receive a generated image in 2-8 seconds depending on tier. Three model pools split the cost/quality/latency curve: Standard (SDXL-class, 1.25 GPU-sec, $0.04), HD (largest model, 2.0 GPU-sec, $0.10), Turbo (4-step distilled, 0.5 GPU-sec, $0.01). The service also supports image variations (image-to-image with style preservation) and inpainting (mask-based regional edits).

The hard parts are continuous step-batching at the denoising loop (new requests join the next step, not the next inference, cutting tail latency from 30s to 6s under variable load), per-tier autoscaling so HD batch demand cannot starve free-tier Turbo, a parallel safety pipeline (CSAM, violence, celebrity face, copyrighted character classifiers fanning out at decode time and gating CDN delivery), per-tier model deployment with separate H100 pools, prompt rewriter LLM enrichment with graceful skip on rewriter failure, watermarking before CDN delivery for provenance, and viral spike recovery via Retry-After backpressure, cross-region overflow, optional tier downgrade, and free-tier shed. Asked at OpenAI, Stability AI, Midjourney, Adobe, Google, and any platform serving diffusion models at scale.

Suggested time: 90 minutes

Loading the workspace...

Learn from other designs

Concepts used in this design

The building blocks this design relies on, each explained in its own lesson.

Related problems

Guides