You scroll through TikTok, Reels, or Shorts, right?
Have you ever wondered why you never get recommended the same video twice? Think about it, you've probably watched thousands of reels, yet somehow the app remembers every single one and never shows it again. If the same content kept appearing, scrolling would quickly become tedious.
So how does TikTok keep track of millions of videos you've watched without breaking a sweat?
In this blog, we'll learn how this system is designed so that your next reel is always a new one, and how the algorithm stays so addictive.
The secret? A clever technology called Bloom Filters.
Bloom filters are probabilistic data structures that can state with 100% confidence that an element does not belong to a set.
But what would be a naive way to keep track of this?
The Naive Approach
Let's say we try to keep track of everything a user watches in a simple set.

However, people watch hundreds of reels every single day, so over time, the set of all posts watched by a user would become extremely large.
So what's the problem? To check the existence of a key in a set, we have to load the entire set into memory and then check. This will be super expensive and time-consuming.
So how can we do it better?
The Key Insight
Let's break it down. The key insight is: once something is watched, you cannot take it back.
That is, once a reel is watched by you, we do not take it out of the set.
This means that storing actual data is not worth it.
This is the concept on which Bloom Filters are designed.
How It Works
Filter = Bit array

Thus we see:
When Bloom filter says No → We can be sure
When it says Yes → We still need to check
Space Efficiency: Bloom Filters take significantly less space to hold the information because they do not store keys and are very efficient in checking existence (just an array lookup).
False Positive Rate: As the number of keys we put in the Bloom filter increases, the false positive rate increases (i.e., it says the key is present but in reality it's not).
Hence when the number of keys increases:
Practical Implementation
Use it whenever:
Examples: Medium recommendations, web crawlers, feed generation, Tinder feed
The Real Magic Behind Your Endless Scroll
Now you know the secret. Every time you open TikTok and get served a perfectly curated feed of fresh content, there's a Bloom filter working silently in the background.
Here's what happens in those milliseconds between your tap and the video appearing:
This isn't just about TikTok. Every major platform uses similar techniques: