Spotify: Sub-200ms Audio Latency & Annoy Vector Search
Instant audio playback and recommendation systems: chunked Vorbis/AAC audio streaming, Annoy approximate nearest neighbor vector search, and event-driven data infrastructure.
Spotify achieved its signature instantaneous playback (sub-200ms audio latency) by pre-fetching the first few seconds of tracks, prioritizing initial byte delivery over total bandwidth, and utilizing approximate nearest neighbor (ANN) vector search for hyper-personalized real-time recommendations.
Sub-200ms Audio Playback Architecture
100M+ tracks, 600M+ monthly active listeners worldwideEliminating audible buffer delay when users tap play, creating the illusion of local music playback on mobile networks.
Chunked audio streaming with dual-phase delivery: the initial 5 seconds are requested with maximum priority without compression buffering; subsequent chunks stream smoothly in background.
High initial HTTP request count per track vs instantaneous audio start time.
Highlight how prioritizing initial byte delivery (TTFB) creates perceived performance superiority over raw maximum download throughput.
Client-Server Model Basics
Understand the fundamental architecture decoupling consumer interfaces from centralized business logic and persistent data stores.
OAuth 2.0: Grant Types & Authorization Code Flow with PKCE
Master delegated authorization: Authorization Code Grant with PKCE (Proof Key for Code Exchange) for SPAs and Mobile, Client Credentials for microservices, Device Flow for CLIs, and deprecation of the Implicit and Password grants.
Data Privacy & Compliance Architecture: GDPR, CCPA, & HIPAA
Engineer for regulatory data privacy: GDPR Article 17 Right to Erasure, CCPA, HIPAA PHI protection, the Crypto-Shredding architecture for immutable big data (Kafka/S3), PII pseudonymization, and regional data residency geo-partitioning.
Spotify: Microservice Squads, Audio Streaming, & P2P Evolution
Stream audio to millions: The Spotify Squad model, Ogg Vorbis chunking, migrating from P2P to CDN edge streaming, and Cassandra/Bigtable playlist storage.
Erik Bernhardsson, Spotify • 2018
Ready to Practice Spotify-Style Systems?
Start with foundational networking, compute, and storage, and build up to complex distributed consensus.