The deduplication logic that passes load tests at 50,000 events per day starts producing false negatives at 10 million. Not because the algorithm is wrong, but because the key lookup itself becomes a throughput problem. At 10 million events per day you have roughly 700 events per minute at sustained load, with peak bursts during pipeline execution windows that might run 3 to 5 times the average. The question shifts from "does this deduplicate correctly?" to "how fast can you check a key, and what happens when the check is slower than the incoming event rate?"
This post walks through what changes architecturally at high event volume, what does not change, and where the common failure modes live when you scale deduplication without rethinking the implementation.
What the Key Store Is Actually Doing
A deduplication key store has three operations: write a key when a new event arrives, check a key when a subsequent event arrives with the same payload, and expire keys after the deduplication window closes. At low volume these operations are trivial. At high volume the write throughput and the read latency of the key store determine whether deduplication is correct or a source of billing errors itself.
A Redis sorted set with TTL expiry works well at moderate volumes. Each key is a string entry; the score is the arrival timestamp. ZADD writes the key, ZSCORE checks whether it already exists, and ZREMRANGEBYSCORE purges expired entries on a schedule. The operations are O(log N) where N is the number of keys in the window.
At 10 million events per day with a 72-hour window, you have up to 30 million keys in the store at peak. A ZSCORE check on a 30-million-entry sorted set is still fast in absolute terms, but under concurrent load from multiple ingest workers it becomes a coordination point. The single Redis instance that handled your first million events per day is a bottleneck at 10 million.
Sharding the Key Store
The solution is to shard deduplication keys by customer_id. Each customer's events go to a dedicated key shard, which contains only that customer's recent events. If you have 200 active customers at 10 million total events per day, most shards have tens of thousands of keys, not millions. ZSCORE checks on small sorted sets are effectively O(1) for practical purposes.
Sharding by customer_id also gives you an operationally useful property: if a customer's deduplication is behaving strangely (elevated duplicate detection or false negatives), you can inspect their specific shard in isolation. Debugging a single sorted set with 80,000 entries is tractable. Debugging a shared sorted set with 30 million entries is not.
The trade-off is operational complexity. You are now managing multiple Redis instances or a Redis Cluster configuration rather than a single instance. Key expiry and memory budgeting need to account for the per-shard distribution. Customers who generate disproportionately high event volumes need their shards sized differently from low-volume customers. This complexity is manageable; it is also work you need to plan for before you need it, not after duplicate billing incidents start appearing.
Bloom Filters as a First-Pass Layer
A probabilistic pre-filter can dramatically reduce the read load on the authoritative key store. A Bloom filter for deduplication works as follows: before checking the Redis sorted set, check a per-customer Bloom filter. If the filter returns "definitely not seen," skip the Redis check and record the event. If it returns "possibly seen," fall through to Redis for a definitive answer.
Bloom filters have a configurable false positive rate. At a 0.1 percent false positive rate, a filter covering 500,000 recent keys uses roughly 900 KB of memory. For most billing deduplication use cases, a false positive means an event that was actually new gets queued for Redis verification; it does not mean a novel event gets discarded. The filter never produces false negatives, so correctness is preserved. The filter reduces Redis load for the roughly 99.9 percent of events that are genuinely new, which at 10 million events per day is about 9.99 million fewer Redis reads per day if your duplicate rate is typical.
This optimization is worthwhile at high volumes. It is probably not worthwhile below a few million events per day, where Redis handles the full load without pressure. Adding a Bloom filter layer early is an over-engineering mistake at moderate volumes; not having it when you scale past a certain throughput threshold is a performance mistake.
Window Management at Scale
A 72-hour deduplication window at 10 million events per day means you are storing roughly 30 million key entries continuously, expiring the oldest 10 million each day and writing 10 million new ones. The expiry operation needs to run on a schedule that keeps the window size stable without causing a thundering herd of deletions.
The naive approach is to run ZREMRANGEBYSCORE on the full sorted set in a scheduled job. At 30 million entries this is a slow operation that blocks other reads and writes on the same instance. The better approach is continuous micro-expiry: each ingest worker that checks the key store also removes a small batch of expired keys as a side effect of the lookup. No scheduled batch job is needed, and the deletion load is spread evenly across the ingest traffic pattern.
For sharded stores, each shard runs its own micro-expiry independently. The total deletion throughput across all shards matches the insertion throughput, so the aggregate key count stays bounded. The implementation adds a few lines to the ingest worker's key store interaction; the operational benefit is the elimination of a scheduled maintenance operation that can cause latency spikes at scale.
When to Use Approximate Counting Instead
For billing systems where an error rate below one in ten thousand is acceptable, approximate deduplication using probabilistic data structures can replace the exact key store entirely. HyperLogLog provides cardinality estimation with a typical error of less than 0.8 percent. For event counting that feeds rate-based pricing, this error is often within the billing rounding tolerance.
We want to be clear about when this is and is not appropriate. Approximate counting is appropriate when the billing unit is event volume and the acceptable variance matches the structure of your rate tiers. If you are billing at $0.0001 per event, a 0.8 percent error on 1 million events is $0.80 of monthly variance. That may be acceptable depending on your minimum charge and rounding conventions. Approximate counting is not appropriate when the billing unit is transaction-level (the event represents a specific financial transaction rather than a consumption unit), or when your customers require exact count reconciliation against their own event logs.
The practical use of approximate counting at Paygentic is as a monitoring layer alongside exact deduplication: HyperLogLog cardinality estimates provide a fast signal for detecting duplicate injection anomalies before the exact key store confirms them. The billing layer still uses exact deduplication. The monitoring layer uses approximate counting for anomaly detection speed.
The Invariants That Do Not Change at Scale
The core requirement does not change: each idempotency key must be checked against the same authoritative record for its deduplication window. You can add layers (Bloom filter, sharding, approximate monitoring), but you cannot remove the exact lookup for events within the window. A deduplication system that skips the authoritative check under load to improve throughput is not a deduplication system. It is a system that accepts duplicates when busy, which is precisely when duplicates are most likely.
The key generation contract also does not change. Clients must generate stable keys that persist across retries. A key generated fresh on each attempt defeats the entire mechanism regardless of how well the server-side deduplication is engineered. At high volume, the cost of client-side key generation bugs scales with event volume. What was one or two duplicate events per day at small scale becomes thousands per day at 10 million events per day, if the duplicate rate from key instability holds constant.
Investing in the deduplication architecture before you need it is cheaper than retrofitting it under load. The failure mode at scale is not catastrophic in the way a database crash is catastrophic. It is a quiet accumulation of billing discrepancies that customers eventually notice and that is difficult to reconcile retroactively once the window data has expired.