Design a Music Upload Service
Design how artists upload albums to a music streaming app: large files over unreliable connections, checking and converting every track, and making a whole release playable at once at its release time.
Problem statement
Design the service that lets artists upload music to a music streaming app. Listeners never use this service directly; they only see songs once a release goes live.
For this exercise, assume:
Releases. An artist, or their label, creates a release: a single or an album of up to 30 tracks, with a title, artist names, track order and cover art. Each track is uploaded as one high-quality audio file, usually 30 to 100 MB and at most 500 MB.
Uploads. Artists may be on slow or unreliable connections. An interrupted upload continues from where it stopped instead of starting over. Retrying any step must not create a second track.
Processing. Each uploaded file is checked (it must be readable audio between 10 seconds and 30 minutes long) and converted into 3 streaming versions at different quality levels. The artist sees each track's state: uploading, processing, ready, or failed with a reason. A failed track can be fixed by uploading a new file.
Release time. The artist submits a release with a release time, and can submit only when every track is ready. At the release time, all tracks of the release become playable together. Before that, listeners cannot find or play any part of it. Many releases are often set for the same popular time, such as midnight at the start of a Friday.
Out of scope: the listener app and playback, search, royalties and payments, checking for copyrighted copies, changing a release after it goes live, lyrics, and running in more than one region.
What to build
- An artist can create a release and upload one audio file per track. An interrupted upload resumes where it stopped, and a retried step never creates a second track.
- Each uploaded file is checked and converted into 3 streaming versions, and the artist sees each track as uploading, processing, ready, or failed with a reason, and can replace a failed file.
- An artist can submit a release with a release time once all its tracks are ready. At that time every track becomes playable together, and nothing of it is visible to listeners before.
At scale
- For this exercise, assume about 100,000 new tracks a day, about 5 TB of new audio, with up to 5 uploads finishing per second at peak.
- For this exercise, assume converting one track takes about 2 minutes of computer time, 95% of tracks should be ready within 30 minutes of their upload finishing, and an upload the service has accepted must never be lost.
- For this exercise, assume up to 20,000 releases, about 100,000 tracks, can share the same release time, and all of them should become playable within 1 minute of it.