---
title: Personalised home screen for a music and podcast app
url: https://gurkanozkan.ai/learn/design/mle-personalised-home-screen-for-a-music-and-podcast-app-01/
markdown: https://gurkanozkan.ai/learn/design/mle-personalised-home-screen-for-a-music-and-podcast-app-01.md
kind: design
role: ML engineering
json: https://gurkanozkan.ai/api/learn/design/mle-personalised-home-screen-for-a-music-and-podcast-app-01.json
---

# Personalised home screen for a music and podcast app

Design the system that picks and orders the shelves and cards on a listener's home screen each time the app opens.

## Constraints

- 100M DAU, ~3 home loads/day each (~3.5k QPS average, ~15k peak)
- p99 latency budget ~200 ms

## What to cover

- **Requirements**: Design the system that picks and orders the shelves and cards on a listener's home screen each time the app opens.
- **Estimates**: 100M DAU, ~3 home loads/day each (~3.5k QPS average, ~15k peak). Catalogue tens of millions of tracks, millions of podcast episodes, hundreds of candidate shelves per user. p99 latency budget ~200 ms.
- **API**
- **Data model**
- **Architecture**: Candidate generation per shelf type: collaborative filtering or two-tower embeddings with ANN retrieval, recent-listening heuristics, editorial pools, new-release and podcast sources.; Ranking model scoring (user, shelf, card) with context (time, device).; Re-ranking for diversity and freshness, and business rules.; Explore/exploit layer (e.g. a contextual bandit over shelf slots and new content).; Feature store with batch user embeddings plus real-time session features; logging of impressions with positions.; Weekly or daily retraining pipeline with automated evaluation gates and an automatic push when a new model clears them.
- **Deep dives**
- **Trade-offs**: batch-precomputed vs real-time ranking (freshness vs cost); engagement vs long-term satisfaction and diversity; music vs podcast mix; exploration cost vs cold-start learning.
- **Evaluation**: Offline: NDCG/recall@k on held-out future sessions, coverage, diversity.; Online: A/B on streams per session, retained listening days, minutes from Home.; Guardrails: skips within 30 s, latency, catalogue concentration.; Daily training/serving skew checks (data validation comparing training and serving feature distributions).

## Reference design

### Requirements

**Functional**: on every app open, choose which shelves to show ("Jump back in", "Made for you", "New episodes", genre and mood shelves, editorial, podcast recommendations), order them, and order the cards within each; adapt to context (time of day, device such as phone, car or TV, market); give each shelf a reason ("Because you listened to …").

**Non-functional and constraints**
- p99 ≤ 200 ms server-side; a cached fallback home if ranking fails — the home screen must never be empty.
- Business rules: licensing availability by market, explicit-content settings, family and kids accounts, pinned editorial shelves, contractual podcast placements.
- **Objective**: not clicks. Primary success = listening that started from Home and that users keep (e.g. streams ≥ 30 s, saves, follows) plus long-term retention (listening days per month). Short-term engagement is balanced against satisfaction and diversity.
- Cold start for new users and new content (new releases, new podcast shows) is a first-class requirement.
- **Assumptions to confirm**: scale as given (100M DAU); music and podcasts share one home; mobile dominates traffic.


### Estimates

- **Traffic**: 100M DAU × 3 loads = 300M loads/day ÷ 86,400 ≈ **3.5k QPS**, peak ~15k QPS (morning commute, evenings).
- **Scoring work**: ~200 candidate shelves per user plus the top ~10 cards of the ~8 visible shelves ≈ 280 model inferences per request → 15k × 280 ≈ **4.2M inferences/s at peak**. Assuming a small multi-task MLP batched on one GPU sustains ~200k inferences/s: 4.2M ÷ 200k ≈ 21 GPUs, ~30 with headroom (or a larger CPU fleet).
- **Batch candidates**: top 20 cards for ~100 shelf types per user = 2,000 ids × 8 bytes ≈ 16 KB per user × 100M ≈ **1.6 TB**, refreshed daily in a wide-column store.
- **Embeddings**: 100M users × 128 dims × 2 bytes ≈ 26 GB; ~50M tracks and episodes × 128 × 2 ≈ 13 GB — the item ANN index fits in memory per replica.
- **Logging**: ~30 impressions per load × 300M ≈ 9B impression rows/day × ~200 bytes ≈ **1.8 TB/day**.
- **Latency budget (p99 200 ms)**: candidate fetch in parallel 40 ms, feature fetch 30 ms, ranking 50 ms, re-ranking and rules 10 ms, assembly 20 ms, ~50 ms headroom for network and tail.


### API

```
GET /v1/home?device=phone&locale=en-GB&tz=Europe/London&session_id=s_77
  → {request_id, ttl_s: 300,
     shelves: [{shelf_id, type: "jump_back_in", title, reason, position,
                cards: [{item_id, item_type: "track"|"album"|"playlist"|"episode"|"show",
                         artwork_url, reason}]}]}

POST /v1/events   (batched from the client)
  {request_id, events: [{type: "impression"|"play"|"skip"|"save"|"follow"|"scroll_depth",
                         shelf_id, item_id, shelf_position, card_position, ts, played_ms}]}

Internal:
  CandidateSource.get(user_id, context, k) → [(item_id, source_score)]
  Ranker.score(batch of (user, shelf, card, context) feature vectors) → {p_stream30, p_save, p_skip}
```
`request_id` ties every impression and outcome to the exact ranking decision, model version and logged propensity.
`ttl_s` lets the client re-show a cached home on rapid re-opens or when offline. Events are batched, delivered at least once and de-duplicated on (request_id, item_id, type), because they become training labels.


### Data model

- **UserProfile** (batch, daily): long-term embedding, genre/artist/show affinities, listening aggregates by time of day and device, subscription tier, explicit filter, market.
- **SessionState** (real time): last N plays and skips, current context, shelves already seen this session.
- **Item**: track/album/playlist/episode/show metadata, embedding, popularity by market, release date, availability by market, explicit flag.
- **ShelfDefinition**: type, candidate source, title template, constraints, editorial owner, eligibility rules.
- **BatchCandidates**: (user, shelf type) → top 20 item ids with scores, generation date.
- **ImpressionLog**: request_id, user, shelf, item, positions, model version, exploration flag, propensity, feature snapshot reference.
- **TrainingExample**: impression joined with outcomes inside a window (stream ≥ 30 s, save, follow, skip < 30 s) and long-term labels (returned within 7 days).

Features logged at serving time are reused for training, which removes most training/serving skew by construction.


### Architecture

```
App ─► Home API ─► Home orchestrator
  ├─ Candidate sources (parallel, each with a timeout):
  │    two-tower ANN (tracks, playlists, shows) · recent listening · new releases
  │    from followed artists and shows · editorial pools · trending by market
  ├─ Features: batch user embeddings and aggregates (feature store, daily)
  │            + real-time session features (stream processor)
  ├─ Ranker: multi-task model on (user, shelf, card, context)
  │            → p(stream ≥ 30 s), p(save), p(skip) → weighted value score
  ├─ Re-ranker: diversity across shelves (genre, music/podcast mix), freshness,
  │            de-duplicate cards across shelves, business rules and availability
  ├─ Explore/exploit: contextual bandit over shelf slots and new content,
  │            logs propensities
  └─ Response + impression log (request_id)
Offline: logs ─► label joins ─► daily/weekly retraining ─► evaluation gates
   ─► registry ─► automatic push when gates pass · daily skew checks
Fallback: precomputed home per user (nightly) served if ranking times out
```


### Deep dives

**Cold start.** New users: onboarding taste picks seed the user embedding; until history builds, use popularity by market, age band and device plus heavier exploration. New items: content embeddings (audio and text for podcasts, artist similarity for tracks) let the two-tower model retrieve them before interactions exist; the bandit gives them a guaranteed exploration budget, then performance decides.

**Position bias and feedback loops.** Top shelves get plays because they are on top. Log positions and propensities; train with position as a feature (set to a constant at serving) or reweight by inverse propensity; a small slice of randomised shelf order measures the bias directly. Without this the model only learns to repeat itself.

**Long-term objective.** Optimising p(stream) alone pushes familiar, repetitive content. The value score combines heads with weights tuned by online experiments against retained listening days; skips and "not interested" signals have negative weight.


### Trade-offs

- **Batch-precomputed vs real-time ranking**: batch homes are cheap and robust but stale — they cannot react to what the user just played or to time of day. Real-time ranking costs a serving fleet but improves freshness; a hybrid (batch candidates, real-time ranking, batch fallback) gets most of the benefit.
- **Engagement vs long-term satisfaction and diversity**: chasing short-term plays narrows taste and inflates clickbait shelves; diversity constraints and long-term labels cost a little immediate engagement for retention.
- **Music vs podcast mix**: podcast sessions are longer and rarer, so raw probabilities are not comparable; calibrate heads and learn each user's mix rather than fixing a quota, with a floor so podcasts get discovered.
- **Exploration cost vs cold-start learning**: exploration spends impressions on uncertain content; cap it (e.g. ~5% of slots), target it at new content, and measure its cost with the logged propensities.


### Evaluation

- **Offline**: NDCG@k and recall@k on held-out future sessions (time-based split, never random); per-head log-loss and calibration; catalogue coverage and intra-home diversity; off-policy estimates using logged propensities for bandit changes.
- **Online**: A/B tests on streams per session from Home, minutes from Home and retained listening days (run long enough — 2–4 weeks — to see retention).
- **Guardrails**: skips within 30 s, "not interested" rate, p99 latency and fallback rate, catalogue concentration (share of streams going to the top 1% of items), podcast discovery rate.
- **Training/serving skew**: daily data validation comparing feature distributions in training data and serving logs; alerts on drift or missing features before a model is pushed.
- **Release gates**: automatic push only if offline metrics beat the incumbent by a margin and no slice (market, device, new users) regresses.


## What a strong design shows

- Defines success as retained listening, not clicks, and builds a value score and guardrails around it.
- Uses a staged pipeline — candidate sources, multi-task ranker, diversity re-ranker, bandit — sized against the latency budget.
- Logs propensities and handles position bias, enabling off-policy evaluation.
- Has a concrete cold-start plan for users and new content.
- Validates offline on future sessions, A/B tests long enough to see retention, and checks training/serving skew daily.

---

*Study material compiled with AI: drafted by a local model (Inkling 2 Mini) from public sources, then checked against those sources by independent AI reviewers (Claude) in November 2026. Not reviewed line by line by a person.*
