Music Generation System
Text-to-Music on a GPU Job Queue
Design a service that turns a text prompt into a finished music track: an asynchronous GPU job queue, a credit system that charges exactly once, and checks that catch outputs copying existing recordings before anyone hears them.
Overview
A user types 'warm lo-fi hip hop with a mellow piano, 80 BPM' and gets a two-minute track. Behind that is a large model running on a GPU for several seconds per track. Published research shows the two main model families: autoregressive models such as Meta's MusicGen, which predict compressed audio tokens one step at a time like a text model predicts words, and latent diffusion models such as Stable Audio, which start from noise and refine a whole clip at once. Commercial services such as Suno and Udio have not published their architectures, so this design treats the model as a black box with a measured speed.
There are three things that shape the system. The work is slow and expensive, so requests go through a queue to a pool of GPU workers. Users pay with credits, so charging must happen exactly once and be refunded if the job fails. And the legal risk is real: in June 2024 the major record companies sued Suno and Udio for copying recordings to train their models (Warner Music settled with both in November 2025 and signed licensing deals), so a service must at least make sure its outputs are not copies of existing recordings.
Questions to ask first
Before drawing anything, settle the scope with the interviewer. These are the questions to ask, each with the answer this design assumes.
- How long are tracks? From 30 seconds to 4 minutes, about 2 minutes on average.
- How many a day? 500,000, with evening peaks 3 times the average.
- How fast must results arrive? Paid users get theirs within about a minute; free users may wait longer.
- Do we train the model? No. We serve a model we have the rights to use.
- What audio format? 44.1 kHz stereo, delivered as MP3, with a lossless download for paid users.
- What must be checked before delivery? The prompt policy, and a fingerprint match against a licensed reference catalog.
The design at a glance
The user app sends a prompt to the generation API, which only charges credits and records the job in PostgreSQL, then puts it on a job queue with a priority and a standard lane. GPU workers with the model already loaded take jobs from the queue and write a lossless master, which is encoded to MP3 with a waveform preview and passed through the output check against the fingerprint index and the prompt policy. Only audio that passes is published and served to the user app through a CDN with signed URLs, and a separate stem job can split published audio later. The Visual Explanation below draws this path, and the first section explains why it starts with a queue.
What you will be able to do
- Explain why generation is an asynchronous job and size the GPU pool from a model's measured speed.
- Charge credits exactly once, and refund exactly once, in SQL that is safe under retries.
- Run priority and standard lanes on one queue without starving either.
- Explain how audio fingerprinting finds a copied recording, and what it cannot find.
- Describe how the two model families differ in speed, streaming and memory.
Key concepts
- Asynchronous job queue
- GPU worker pool
- Priority lanes
- Credit ledger
- Autoregressive audio tokens
- Latent diffusion
- Audio fingerprinting
- Stem separation
- CDN delivery
Functional requirements
- Accept a prompt with optional genre, tempo, key, duration and instrumental flag; return a job id at once
- Report job progress and deliver the finished track with a waveform preview
- Charge credits by duration when a job is accepted; refund automatically if it fails or is blocked
- Check every output against a reference catalog and the content policy before it is published
- Keep a personal library with playback, download and sharing
- Split a finished track into stems (vocals, drums, bass, other) as a separate paid job
Non-functional requirements
- Priority-lane jobs start within 30 seconds at p95 during normal load (a target we chose)
- No track reaches a user without passing the output check
- Credits are charged once per accepted job and refunded once per failed job, whatever retries happen
- A worker crash loses no job: the job returns to the queue
- Playback starts in under 1 second from the CDN (a target we chose)
Interview questions
- Why not generate the track inside the HTTP request?
- How many GPUs do you need?
- How do you make sure credits are charged exactly once?
- How do you stop outputs that copy existing songs?
- Can the user hear the track before it finishes?
- How do free and paid users share the GPUs fairly?
- What legal context should the design reflect?
Sign up free to read the full topic
More System Design topics
Start free on Cariara · Coding problems · System design studio