Count 1 billion unique visitors in 12 KB: HyperLogLog steps in wpipe.
Counting unique visitors shouldn't bankrupt your Redis RAM or choke your SQL database. wpipe-steps gives you native Redis HyperLogLog steps to estimate billions of distinct items in 12 KB.
Here is how you use Redis HyperLogLog Cardinality Estimation in a production pipeline with wpipe-steps:
from wpipe import Pipeline
from wpipe_steps.database.redis.hyperloglog import (
redis_hll_add_sync,
redis_hll_count_sync
)
pipeline = Pipeline(pipeline_name="unique_traffic_counter")
pipeline.set_steps([
# Add unique visitor IP addresses
redis_hll_add_sync.as_step(
name="record_visitor",
key="traffic:unique_ips:2026-09",
elements=["192.168.1.1", "10.0.0.42", "172.16.0.99"]
),
# Retrieve approximate cardinality in O(1) time
redis_hll_count_sync.as_step(
name="get_unique_count",
keys=["traffic:unique_ips:2026-09"],
response_key="unique_visitors"
)
])
result = pipeline.run({})
print(f"Estimated unique visitors: {result['unique_visitors']}")
Why developers love wpipe-steps:
- 196 cataloged steps covering Redis, ClickHouse, MySQL, WAF, S3, Docker, and local HuggingFace AI.
- Lazy-loading imports for instant sub-100ms startup times.
- Clean
.as_step()factory interface.
Check out the full repository on GitHub!
Top comments (0)