Cut Memory for a Restricted ASIN Check Using a Bloom Filter
Last updated: November 29, 2026
Quick Overview
A checkout service must check every cart item against a set of 100 million restricted product ids, and holding them in a hash set needs many gigabytes per host. Implement a Bloom filter front check and size it for a 1 percent false positive rate.
Amazon
November 29, 20260
0
0 solved
A checkout service must check every cart item against a set of 100 million restricted product ids, and holding them in a hash set needs many gigabytes per host. Implement a Bloom filter front check and size it for a 1 percent false positive rate.
Compliance and hazmat checks run on every Amazon checkout, so the lookup must be in-process and fast, but the restricted list is huge. The interviewer checks probabilistic data structure fundamentals, the sizing math, and how to make false positives harmless.
What the Interviewer Expects
- Explains no false negatives and tunable false positives
- Derives bit array size and hash count from n and p
- Uses double hashing to get k positions cheaply
- Confirms possible hits against an exact store
- Explains why deletes are not supported and what to do about it
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you handle ASINs being removed from the restricted list?
- How would you ship a rebuilt filter to thousands of hosts safely?
- How does a counting Bloom filter or a cuckoo filter differ?
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
- 100M restricted ASINs; checks run per cart item with sub-millisecond budget.
- A false negative is unacceptable; a false positive can cost one remote lookup.
- Target 1 percent false positives....
High-Level Design
Sizing: bits and . For that is about 120 MB, versus roughly 6 to 10 GB for a Python set of strings. Each key de...