Music App Recommendation Algorithm: Technical Architecture + Business Architecture
(Industrial-grade recommendation system referencing Spotify, NetEase Cloud Music, WeSing; mapped to concrete business scenarios including Daily Recommendation, Private FM, post-search similar recommendations, AI-generated music distribution, playlist continuous playback, commuting/fitness/bedtime scenarios; architected for Java microservices + Flink + vector database + model serving deployment)
I. Business Architecture: Define Scenarios First, Then Algorithms
Music app recommendations cannot rely on a single model for all use cases; it is a paradigm of multi-scenario × multi-objective optimization.
Scenario User Mindset Core Metrics Algorithm Focus
Home Page "Daily Recommendation" What should I listen to today? Completion rate, favorite rate, next-day retention Long-term user profile + multi-objective fine-ranking
"Private FM / Auto-continuous Playback" Don’t make me skip tracks 30s skip rate, session duration Real-time session I2I + sequential models
Post-search / Track-click "Similar Recommendations" Find similar tracks based on this song Click-through rate, add-to-playlist rate Item-CF + audio/text multimodal retrieval
"AI-Generated Music" Distribution My generated tracks / tracks created by others Post-generation listen-through rate, reuse rate, creator retention Content cold-start + Bandit exploration
Scenario Playlists (Commuting / Fitness / Bedtime) Fit the current moment and context Scenario completion rate, bounce rate Rule-based templates + BPM/energy tag recall
New Songs / Independent Artist Cold-start Allocate traffic to emerging creators Valid plays, favorite rate Multimodal DSSM + traffic support policies
Music-specific pitfalls:
• Loop playback ≠ fatigue (opposite to news feed logic)
• No playback ≠ negative sample (may simply be lack of exposure)
• Negative samples are strictly defined as: skipping within 30 seconds / clicking "dislike"
[Product Layer] Home Page / FM / Search / AI Creation / Scenario Playlists / Operational Placements
↓ Scenario Routing (scene_id + context)
[Strategy Layer] Scenario Strategy Engine (cold-start templates, new song promotion, fatigue control, copyright filtering)
↓
[Algorithm Layer] Recall → Coarse Ranking → Fine Ranking → Re-ranking → Reason Generation
↓
[Data Layer] Behavioral Logs / Feature Platform / Model Serving / Vector Index / A/B Testing
II. Technical Architecture: Five-Stage Pipeline (Online + Offline Dual Pipeline)
Client (Android/iOS) │ Tracking events: play / skip(30s) / save / add_to_playlist / replay / share
▼
API Gateway → Reco Gateway (Java/Spring)
│ Authentication, scenario parsing, graceful degradation, timeout circuit breaking
▼
[Online] Filter (copyright / blacklist / played ≥N times / disliked) ▼
Recall (multi-channel parallel) → Merge / Rank Fusion ▼
Pre-Rank (lightweight twin-tower distillation) → Rank (MMoE multi-objective) → Re-Rank (MMR / DPP / frequency control) ▼
Reason Generation (templates / LLM) → Response (P99 < 100ms)
[Offline / Near Real-Time]
Flink real-time features (second-level) + Spark offline training + vector index rebuilding (Faiss/HNSW)
Models: CF / Twin-Tower / DSSM / MMoE / Sequential Transformer / Bandit
Note: The officially documented architecture of NetEase Cloud Music follows this exact structure: Feature Engine → Recall Engine → Ranking Engine → Manual Intervention → Online Serving.
User-side
• Long-term profile: preferred genres, artists, languages, BPM preferences, favorite track sets
• Short-term session: last 20 tracks (triggers), current context (time / device / network / location) • Negative feedback: 30s skips, dislikes, removed from playlists
Item-side (Music-specific) • Behavioral features: completion rate, favorite rate, add-to-playlist rate, skip@30s
• Audio features: BPM, key, loudness, Mel spectrogram → CNN Encoder → audio embedding
• Text features: song title / lyrics / playlist title / artist bio → BERT/LLM embedding
• Multimodal fusion: CLIP-style contrastive learning to align audio and text in the same hypersphere
Context-side
• Morning / afternoon / night; commuting / fitness / bedtime; Wi-Fi / cellular; in-car mode Real-time processing: Flink consumes Kafka tracking events to update "recent skips / favorites" to Redis in seconds, ensuring online-offline consistency for fine-ranking.
Recall Channel Applicable Business Scenario Implementation
Item-CF / Swing Similar tracks, FM continuous playback Co-occurrence matrix, built offline
User-CF Neighbors Cold-start users (friends’ listening habits) Social login fallback
Twin-Tower U2I (behavioral) Core of Daily Recommendation User tower × Song tower ANN
Multimodal DSSM (audio + text) New songs / AI-generated track cold-start Enters recall pool even with zero behavioral data
Session I2I Next track for Private FM Real-time sequential co-occurrence
Trending / Rising Star / Operational Playlists Fallback + new song promotion Rule-based pool
Scenario Tag Recall (BPM / energy / mood) Commuting / fitness / bedtime Tag inverted index + multi-level relaxation
Scores from all channels must be min-max or rank-normalized before weighted fusion; otherwise, CF scores (0~100) will dominate content recall scores (0~1).
Vector retrieval uses Faiss (HNSW / IVF-PQ) with O(log N) complexity. • Copyright / geo-restricted content
• Tracks played ≥ N times (loop playback does NOT count as fatigue)
• Explicit dislikes, blacklisted artists
• Abnormal audio duration < 30s
• Deduplication of tracks already exposed in current session
• Lightweight twin-tower (distilled version of fine-ranking twin-tower) or LR / GBDT with limited cross features
• Objective: unify incomparable scores from different channels into comparable "coarse-ranking scores"
• Engineering value: protects fine-ranking service from excessive QPS pressure
Music cannot be ranked solely by CTR; typical multi-objectives include:
• Completion rate
• Favorite / save rate (strong positive feedback)
• 30s skip rate (negative signal)
• Add-to-playlist rate
• Long-term retention contribution (optional RL)
Model: MMoE / PLE (multi-expert shared bottom layers, gates allocate weights per objective)
Features: user×item cross features, session sequences, audio similarity, graph proximity, context.
Score fusion: CEM / Bayesian optimization for weight search—avoid arbitrary manual weighting.
Business pitfall: Completion rate is a delayed feedback metric (user may listen for 3 minutes before completion). Sample attribution requires delay correction; otherwise, the model will learn incorrectly.
• Frequency control: No more than K consecutive tracks by the same artist / genre / language
• MMR / DPP: Trade-off between relevance and diversity to break information cocoons
• New song Bandit: Thompson Sampling allocates small exploratory traffic to cold-start tracks; expand traffic if completion rate is high
• Scenario hard rules: Reduce BPM > 140 for bedtime; increase energy for fitness; avoid long intros while driving
• Fatigue control: Exposure decay for the same track within 7 days (loop playback incurs no penalty)
• Manual intervention: Whitelist forced insertion (newly signed artists), blacklist takedown
• Recommendation reasons: "Because you favorited Jay Chou" / "Belongs to late-night electronic" / "AI-generated in your preferred style"
• Cover art optimization (CNN + Thompson Sampling)
• Mixed card layout: singles / playlists / artists / AI-generated works
III. Cold-start Specialization (Critical for Music Apps)
New Users
New Songs / AI-Generated Tracks
• Zero behavioral data → use audio+text embedding → ANN to find similar "warm" tracks → I2I2U delivery to audiences of those warm tracks
• Cold-start multimodal DSSM directly computes U-I matching scores
• Bandit small-traffic exploration; reclaim traffic if 30s skip rate is high
• Creator side: immediately add to "My Works" + push to Release Radar of users with matching style preferences
IV. Engineering Stack Recommendations (Java Team Friendly)
• Gateway / Business logic: Spring Boot + Spring Cloud Gateway
• Real-time features: Flink + Kafka + Redis (session features) • Offline processing: Spark on YARN / TF-on-Spark for training
• Vector database: Standalone Faiss (HNSW) service, or Milvus
• Model serving: TensorFlow Serving / TorchServe via gRPC
• Experimentation: Custom A/B testing (layered bucketing) + metrics dashboard (skip@30s, completion, retention, catalog coverage)
• Degradation: recall timeout → trending pool; fine-ranking failure → serve coarse-ranking scores directly
V. Metrics Guardrails (Avoid Obsessing Over Clicks Alone)
• Short-term: skip@30s ↓, completion ↑, favorites ↑, session duration ↑
• Mid-term: next-day / 7-day retention, discovery rate (proportion of new artists heard) • Long-term: catalog coverage, long-tail exposure ratio, creator retention
• Diversity: average exposed albums per user, number of secondary categories
VI. Summary Mapping (Business ↔ Technology)
Daily Recommendation → Long-term profile twin-tower + MMoE + MMR re-ranking
Private FM → Session I2I + Sequential Transformer + frequency control Similar Recommendations → Item-CF + multimodal ANN
AI-Generated Distribution → Content DSSM cold-start + Thompson exploration + creator radar
Scenario Playlists → Tag inverted index (BPM/energy) + rule templates + multi-level relaxation
New Song Cold-start → CLIP multimodal + I2I2U + whitelist promotion