Track Seen Stories Per User With a Bloom Filter

Last updated: November 29, 2026

Quick Overview

The Stories tray needs to know which stories each viewer has already seen, across billions of viewers. Implement a memory-efficient seen-set using a Bloom filter and explain which error direction is acceptable.

Meta
Software Engineering Fundamentals
Software Engineer
Meta
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Medium

0

0

0 solved


The Stories tray needs to know which stories each viewer has already seen, across billions of viewers. Implement a memory-efficient seen-set using a Bloom filter and explain which error direction is acceptable.

Instagram and Facebook Stories rank unseen rings first, and storing exact seen-sets for every viewer is expensive in memory at Meta's scale. In a memory and performance round the interviewer wants you to size the filter from first principles, pick the right error direction for the product, and know the limits (no deletes, saturation).

What the Interviewer Expects
  • Derives bit count and hash count from expected items and target false positive rate
  • Uses double hashing to get k positions from one digest
  • States that false positives mark an unseen story as seen while false negatives never happen, and argues whether that is acceptable
  • Compares memory against an exact set of 64-bit ids
  • Handles expiry by rotating filters since standard Bloom filters cannot delete
Key Topics to Cover
Bloom filters
probabilistic data structures
memory sizing
false positive tradeoffs
hashing
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
  • What if the product team says hiding even one unseen story from a close friend is unacceptable?
  • How would you handle a power user who views far more stories than the expected count?
  • Would a counting Bloom filter or a cuckoo filter be better here, and why?
  • Where would this live: on device, in a cache tier, or in the ranking service?
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
  • mark_seen(viewer, story) and is_seen(viewer, story).
  • Roughly 500 story views per viewer per day, stories expire after 24 hours.
  • Target false positive rate 1 percent, zero false negatives.
  • ...
High-Level Design

A Bloom filter is an m-bit array with k hash functions. Adding sets k bits; a lookup returns 'maybe present' only if all k are set. Optimal sizing for n items and false positive rate p is $m = -n\ln p...


Submit Your Answer
Markdown supported