What is HyperLogLog in Redis?
Answer
HyperLogLog is a probabilistic data structure in Redis that estimates the cardinality (number of unique elements) of a set with very low memory usage — approximately 12KB per HyperLogLog, regardless of the number of unique elements counted. PFADD key element [element ...] adds elements; PFCOUNT key [key ...] returns the estimated unique count. The error rate is approximately 0.81%. This is ideal for counting unique page views, unique visitors, or unique searches at massive scale where storing every individual user ID in a Set would consume enormous memory. For example, counting unique daily visitors across millions of users uses 12KB instead of potentially gigabytes. PFMERGE merges multiple HyperLogLogs, enabling counting unique visitors across date ranges.
More Redis Questions
View all →- Intermediate What is Redis Cluster and how does it shard data?
- Intermediate What is the difference between Redis Sentinel and Redis Cluster?
- Intermediate How do MULTI and EXEC work in Redis transactions?
- Intermediate What is WATCH and optimistic locking in Redis?
- Intermediate What is Lua scripting in Redis and when should you use it?