Design Near-Duplicate Image Detection for Uploaded Photos
Last updated: November 29, 2026
Quick Overview
Design a service that checks every photo uploaded to Facebook and Instagram against a database of known images (for example previously removed violating content) and flags near duplicates, even after cropping, resizing, or recompression.
Meta
November 29, 20260
0
0 solved
Design a service that checks every photo uploaded to Facebook and Instagram against a database of known images (for example previously removed violating content) and flags near duplicates, even after cropping, resizing, or recompression.
Meta open sourced perceptual hashing for this purpose, and integrity infrastructure is a common interview domain. The interviewer checks that you choose perceptual over cryptographic hashes and can design a fast Hamming-distance lookup at upload rate.
What the Interviewer Expects
- Explain why cryptographic hashes fail for near duplicates
- Use a perceptual hash and Hamming distance threshold
- Design a scalable lookup for nearest hashes
- Place the check in the upload path with a latency budget
- Handle threshold tuning and false positives
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- How do you search 1 billion 256-bit hashes for distance under 30 quickly?
- What about a mirrored or heavily cropped image?
- Should the check block the upload or run asynchronously?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Functional: compute a fingerprint per uploaded photo; compare against a bank of known fingerprints; on match, take the action attached to that bank entry (block, send to review, label).
**Non-fun...
High-Level Design
On upload, the media service computes a perceptual hash (256 bits from a DCT of a downscaled grayscale image) and calls the match service. The match service returns the closest bank entries wi...