Perceptual Hash
Fingerprint images/audio that are similar visually — detects near-duplicates despite resize, compression, or minor edits.
Interview tip Lead with a 30-second definition, then one real system example and name 2–3 designs where Perceptual Hash is non-negotiable.
① What it is (30 seconds)
Fingerprint images/audio that are similar visually — detects near-duplicates despite resize, compression, or minor edits.
② How it works in system design
pHash, dHash reduce image to compact hash where similar images have close hamming distance. Compare hashes in buckets — not cryptographic security.
Typical placement
Client→Edge / Gateway→Perceptual→Services→Data stores
③ Concrete system design example
Scenario: Google Photos duplicate detection: perceptual hash of each photo → bucket similar hashes → ML refine duplicates for "same moment" suggestions.
④ Important interview Q&A
| Question | Answer |
|---|---|
| Perceptual vs SHA256? | SHA changes completely on 1-bit flip; perceptual similar images → similar hashes. |
| Hamming distance threshold? | Tune distance ≤ N as duplicate candidate; false positives need second-stage model. |
| Video duplicates? | Hash per frame or keyframes; temporal alignment for clips. |
⑤ Seen in these system designs
- Google Photos Duplicate — core algo
- Instagram — CSAM/near-dup detection
- Chrome Malware — binary similarity
In interviews, after explaining the concept, say: "This shows up directly in …" and link two designs.
⑥ Revision checklist
- Near-duplicate not cryptographic
- Hamming distance
- Second-stage ML
- Scale via bucketing