There's more...
In the preceding example, we could also use a Redis set to count the number of users. Let's take a look at the difference between using a bitmap and a set in this example from a memory usage perspective.
As we've seen, every user needs one bit in the bitmap, regardless of whether the user has ever used the feature or not. Suppose there are two billion users on Relp; we need to allocate two billion bits, which is roughly 250 MB, in memory. If we use a Redis set to implement the same counting functionality, we only need to store the users who have used the Relp feature in the set.
Suppose we store the user ids as 8-byte integers. If a Relp feature is very popular and 80% of Relp users (1.6 billion) have used it, we need to allocate ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access