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
Software Engineering Fundamentals
Data Engineer
Amazon
November 29, 2026
Data Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

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
Bloom filter
memory optimization
hashing
false positives
probabilistic data structures
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. 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 Problems
Sample 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: m=−nln⁡p(ln⁡2)2≈9.6nm = -\frac{n \ln p}{(\ln 2)^2} \approx 9.6n bits and k=mnln⁡2≈7k = \frac{m}{n}\ln 2 \approx 7. For n=108n = 10^8 that is about 120 MB, versus roughly 6 to 10 GB for a Python set of strings. Each key de...


Submit Your Answer
Markdown supported