List functional requirements for the system (Ask the chat bot for hints if stuck.)...
List non-functional requirements for the system...
Estimate the scale of the system you are going to design...
Define what APIs are expected from the system...
GET songs/song_id
sample response
{
song_name: "xxx",
artist: "xx",
length: "xxxx"
}
GET artists/artist_id
sample response
{
artist_name: "xxx",
songs: [] song_id,
}
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
We can use relational database for user, song metadata, playlist information. But we also need a blob storage to store the actual audio files.
User table
name
user_id
genre
playlists: [] playlist_id
Playlist table
user_id
playlist_name
playlist_id
songs: [] song_id
Song Metadata table
name
song_id
artist
length
last_updated_time
album_id
chunks: {url: xxxx, status: not_uploaded/uploaded}
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
Client -> load balancer -> CDN -> server -> music uploading service
-> music streaming service
both services point to both S3 and relational database
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
When a user streams music
When an audio file is uploaded
When a user searches for a song
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Audio uploading
Audio files can be split into chunks -> all the chunks are dumped into a queue -> consumer pulls jobs into processor to process the chunk (encoding, transcoding..etc) -> a heartbeat and status monitor worker listens to the processor and consumer and update the status of the chunks accordingly. If a processor fails, a new processor will replace it, and repull the jobs from the queue and process it again. If a job needs to retry, processor tries it 3 times on the spot and if it still fails, update the status to be failed and throw it in a dead letter queue.
Explain any trade offs you have made and why you made certain tech choices...
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?