Katkat

Design Music Search, Playlists, and Playback Controls

AmazonSoftware Engineer · Onsite

Last updated

This problem tests the ability to design a scalable music streaming architecture, focusing on data modeling for search indices, conflict resolution in distributed state management, and robust API design for real-time playback control.

System Design: Music Streaming Infrastructure

Design a backend architecture for a music streaming service that supports three primary pillars: a catalog search engine, persistent user-defined playlists, and synchronized playback controls across multiple devices.

Requirements

1. Catalog & Search

  • Support search by artist, album, and song title.
  • The catalog contains tens of millions of tracks. Updates to metadata should reflect in search results with low latency.

2. Playlists

  • Users can create, update, and reorder songs within playlists.
  • Playlists must support high concurrency (e.g., multiple users editing a shared playlist) and ensure consistency.

3. Playback Controls

  • Users may control playback on one device (e.g., phone) while listening on another (e.g., smart speaker).
  • The system must handle state synchronization (play, pause, skip, seek) while managing command ordering and potential latency.

Tasks

  1. Data Model: Propose a storage strategy for the immutable music catalog versus the mutable playlist state. How do you distinguish between these two access patterns?
  2. API Design: Define the interface for playback controls. How do you handle "out-of-order" commands (e.g., a 'play' command arriving after a 'pause' command due to network jitter)?
  3. Consistency: How do you prevent race conditions when two users reorder the same playlist simultaneously?
  4. Scalability: Sketch the service boundaries. How do you ensure that search traffic does not impact playback stability?

Constraints & Assumptions

  • Assume 50 million monthly active users.
  • Global availability is required; users may switch networks frequently.
  • Playback state changes are latency-sensitive (sub-200ms target).

Hints

Hint 1

Consider using an inverted index (e.g., Elasticsearch) for the catalog while using a relational or document database with optimistic locking for user playlists.

Hint 2

For multi-device playback, use a versioning system or vector clocks for state changes to ensure commands are processed in the intended logical order.

Hint 3

Decouple the playback control plane (state management) from the media delivery plane to ensure that a spike in search traffic does not interrupt audio streams.

Follow-up questions

  • How would you implement a 'caching strategy' for search results to reduce database load?
  • If you were to implement a 'collaborative' playlist editing feature, how would you handle conflict resolution compared to single-user edits?
  • How would you instrument the system to detect if a specific device is consistently failing to receive playback commands?