System Design: Shazam (Walnut Tune: Audio Fingerprints, Noisy Rooms, 150M Tracks)
Goal: Design our own music recognition service, like Shazam. We call it Walnut Tune. A person holds up a phone, and within a few seconds we name the recording that is playing.
We search 150 million tracks, about 50 million times a day, often in loud rooms.
Reading guide: Sections 1 to 5 set up the problem, the core idea and the design. Sections 6 to 15 are deep dives. Sections 16 to 22 cover capacity, failures, bottlenecks, regions, security, operations and trade-offs. Section 23 covers the interview, section 24 how we measured, and section 25 further reading.
New to audio? Start with section 3. In an interview, sections 2 to 8 are the core.
1. What We Are Building
🔒 Premium section
2. Requirements and Scale
2.1 What the System Must Do
| ID | Requirement |
|---|---|
| FR-01 | Name the recording playing near the phone from 3 to 12 seconds of sound. |
| FR-02 | Return title, artist, album, cover art, position in the recording and links to play it. |
| FR-03 | Work in noisy places such as coffee shops and bars. |
| FR-04 | Say "no match" when we are not sure, instead of guessing. |
| FR-05 | Work offline, and answer when the phone is back online (Jake). |
| FR-06 | Keep a history of recognitions, synced across the user's devices. |
| FR-07 | Auto-listen mode, which listens in the background and saves each new track. |
| FR-08 | Add new releases daily and remove tracks that are taken down. |
| FR-09 | Offer an SDK, a code library, so other apps can recognize music. |
| FR-10 | Serve business tenants, such as radio monitoring (Ryan) and custom catalogs. |
2.2 How Well It Must Do It
NFR-01. Server time under 1 s at p99 for a hot-tier match, under 2 s if we also search the cold tier (tiers: section 5). "p99" means 99 of every 100 requests finish faster than this. From tap to answer, the user waits about 3 to 6 seconds, mostly listening.
NFR-02. Handle 9,000 requests a second for minutes at a time. That is 6,000 recognitions a second at a spike (section 2.3).
NFR-03. Wrong answers must be very rare. A false positive is a wrong answer. A false negative is a miss, where the recording is in our catalog but we say "no match".
A miss costs Emily a few more seconds of listening. A wrong answer shows her a song she didn't hear, and she stops trusting the app. So we accept more misses to get fewer wrong answers. Our target is at most 1 wrong answer in 10,000 answered queries (our planning number).
More tracks give a wrong track more chances to line up by luck. So before launch we set the acceptance rules again on the full index (section 7.5).
NFR-04. New tracks are searchable within about 15 minutes of a label sending them.
NFR-05. Privacy and small requests. No audio leaves the phone, and a request is about 2.4 KB. The fingerprint can't be turned back into sound. We delete it after at most 24 hours.
NFR-06. Keep answering through failures. A lost server may slow answers, not stop them. A lost region sends its users to another region (section 17).
2.3 The Numbers
- Users. 300 million monthly users, the size Apple reported for Shazam (2024).
- Recognitions. 50 million a day.
- Average rate. 50,000,000 / 86,400 seconds is about 580 recognitions a second.
- Evening peak. About 3 times the average, so about 1,750 a second.
- Spikes. A halftime show or a TV ad with a song makes many people tap at once. We plan for 10 times the average, about 6,000 a second for several minutes.
One recognition can take up to three requests, at 3, 6 and 12 seconds of sound (section 4).
- Requests per recognition. About 1.5 on average (our planning number). We expect most clips to match at the first or second try.
- Evening peak. 1,750 x 1.5 is about 2,600 requests a second.
- Spike. 6,000 x 1.5 is 9,000 requests a second. That is our design target.
The industry had about 253 million recording IDs, and about 106,000 new tracks arrived each day (Luminate 2025, as reported).
- Catalog. 150 million recordings, after removing duplicates.
- Growth. About 100,000 new tracks a day, about 1.2 a second.
A hash is one small number made from a pair of loud points in the sound (section 3). The index is the big table that finds tracks by hash (section 5).
- Index size. At 30 hashes per second of audio, a 3.5-minute track needs about 50 KB of index. So 150 million tracks need about 7.6 TB (section 8).
- Hot tier. The 10 million most played and newest tracks, kept on their own servers and searched first, about 0.5 TB (section 5.4).
A report on the same Luminate data said 88% of tracks had 1,000 streams or fewer. So a small hot tier can answer most queries.
Last, the request. Ten seconds at 30 hashes a second is 300 hashes. Each takes 8 bytes, the hash and its time in the clip, so a request is about 2.4 KB. Raw sound would be about 220 KB.
2.4 Out of Scope
- Humming, singing, covers and live versions. They need a melody model.
- Lyrics and recommendations. Other services own these. We pass them the recording ID.
- Accounts, payments and label contracts. These work like any web app.
3. How Audio Fingerprinting Works
🔒 Premium section
4. The API and Data
🔒 Premium section
5. High-Level Design
🔒 Premium section
6. Deep Dive: The Fingerprint (on the Phone)
🔒 Premium section
7. Deep Dive: Matching and Scoring
🔒 Premium section
8. Deep Dive: The Index at 150M Tracks
🔒 Premium section
9. Deep Dive: Adding New Music
🔒 Premium section
10. Deep Dive: Noisy Rooms and Short Clips
🔒 Premium section
11. Deep Dive: On the Phone
🔒 Premium section
12. Deep Dive: Results, Metadata and History
🔒 Premium section
13. Deep Dive: Spikes (Halftime Show, TV Ad)
🔒 Premium section
14. Deep Dive: B2B Tenants (Radio Monitoring, Custom Catalogs)
🔒 Premium section
15. Deep Dive: v2 Neural Fingerprints
🔒 Premium section
16. Capacity
🔒 Premium section
17. What Happens When Each Part Goes Down
🔒 Premium section
18. Bottlenecks
🔒 Premium section
19. Regions and Data
🔒 Premium section
20. Security and Privacy
🔒 Premium section
21. Running It
🔒 Premium section
22. Trade-offs
🔒 Premium section
23. In the Interview
🔒 Premium section
24. How We Measured
🔒 Premium section
25. Further Reading
🔒 Premium section
Explore the Technologies
🔒 Premium section