Design a Podcast Subscription Feed API and Data Model
Design podcast and episode publishing, subscriptions, and a feed with precise HTTP semantics, relational constraints, SQL queries, and scalable projections.
Problem statement
For this exercise, assume creators register podcasts and publish immutable episode or audio-clip metadata, while listeners subscribe or unsubscribe and browse content from their current subscriptions.
Start with the external API: choose methods, paths, request and response bodies, status codes, caching and pagination headers, validation errors, and idempotency behavior.
Support both a reverse-chronological episode feed and a grouped browse response that returns a bounded page of podcast channels with a bounded child page of clips for each channel; define independent continuation behavior for the outer and inner collections.
Compare SQL and NoSQL models against the access patterns and integrity requirements.
For the remainder of this exercise, use a relational source of truth and show the SQL queries, constraints, or transaction operations that power creation, subscription, and reads; a denormalized NoSQL model may still be proposed as a derived read projection.
Finally, explain API versioning, read-heavy scaling, and highly skewed shows without losing relationship integrity or producing duplicate episodes. Audio transcoding, recommendations, reviews, ads, billing, and full-text search are outside scope.
What to build
- An authorized creator can add one podcast with validated metadata and receive a stable podcast identifier.
- A creator can idempotently publish immutable episode metadata under a podcast.
- A listener can subscribe or unsubscribe from a podcast with an idempotent outcome.
- A listener can page through a deduplicated reverse-chronological feed of episodes from currently subscribed podcasts.
- A listener can page through subscribed podcast channels and receive a bounded, independently continuable episode or clip slice for each returned channel.
At scale
- For this exercise, support 50 million listeners, 5 million podcasts, up to 2,000 subscriptions per listener, and one show with 20 million subscribers.
- For this exercise, peak at 2,000 episode publishes and 200,000 first-page feed reads per second, with p95 feed latency below 300 ms.
- For this exercise, an acknowledged episode should become eligible for subscriber feeds within 60 seconds at p95; API clients may retry every mutation.
- For this exercise, retain episode metadata indefinitely, use stable cursor pagination, and keep authoritative creator, podcast, episode, and subscription relationships recoverable from one source of truth.