Back to results for “Redis Memory Optimization”
Redis › HyperLogLog in Redis

How accurate is a Redis HyperLogLog's estimated count, and why might a small amount of inaccuracy be an acceptable tradeoff?

Intermediate

Answer

A Redis HyperLogLog typically has a standard error of about zero point eight one percent, meaning the estimated count will usually be very close to the true value, and this small inaccuracy is often an entirely acceptable tradeoff in exchange for using a fixed, extremely small amount of memory instead of the potentially massive amount required to store and check every individual unique item exactly.
-- A HyperLogLog uses roughly 12 kilobytes
-- regardless of counting a thousand or a billion items
PFADD large_dataset 'item1' 'item2' -- ... millions more
Real-world example An analytics platform accepts a small margin of error in its unique visitor counts in exchange for using a tiny, predictable amount of memory, since knowing the count is approximately ten million rather than exactly ten million is perfectly sufficient for their reporting needs.

Common follow-ups: In what scenarios would this small margin of error actually matter?;How does the error rate change as the number of unique items grows very large?