This article explains how we use a short-lived Redis idempotency lock to protect external vendor transfer webhooks from race conditions, duplicate retries, and out-of-order delivery. By using an atomic SetNx cache key with a bounded TTL, we ensure each transfer status is processed exactly once within a retry window, preventing duplicate database updates, events, and side effects while keeping the system resilient and recoverable.

| Challenge | Approach | Results |
|---|---|---|
| Webhooks are at-least-once: duplicates and retries are normal Deliveries can arrive concurrently and out of order Duplicate work can leak into user-facing side effects (confusing state, repeated updates, inconsistent timelines) | Treat cache as a coordination primitive, not a read-optimization layer Acquire a short-lived idempotency lock per transfer-status before side effects Use deterministic keys + TTLs to stay safe and self-healing | More consistent user-facing outcomes during retry bursts Effectively-once processing per transfer status within a bounded window Lower database and event-bus pressure, plus fewer duplicate downstream actions |
Fintech webhook pipelines live in the real world: vendor retries, network timeouts, and horizontal scaling are all expected. In money movement, “processing the same thing twice” is rarely a benign failure mode. It can create duplicate state transitions, duplicate event emissions, and operational noise that slows teams down. You can find more on what changed in Version 4 and SoLo Funds' B Corp recertification in related posts.
This post shares a portable pattern in webhook processing: a Redis-backed idempotency lock with a bounded TTL.
When duplicate or out-of-order webhook processing leaks into product behavior, the experience can feel inconsistent or untrustworthy, even if the underlying system eventually converges.
Common symptoms :
We treat these as correctness problems with user-visible impact, not just backend quirks.
A helpful way to frame webhook idempotency is as a product contract:
The Redis lock pattern below is one practical way to enforce that contract at the edge of your system.
Most vendor webhooks should be assumed to have at-least-once delivery semantics:
This leads to classic distributed-systems hazards:
The goal isn’t to stop retries, retries are healthy behavior. The goal is to make retries safe.
In this workflow, Redis is not used as a generic caching layer to speed up reads. We use it as a low-latency coordination mechanism: a short-lived lock that prevents duplicate work from touching stateful systems.
A practical way to think about it: a Redis round trip is typically fast enough to absorb “retry bursts” before your database or event bus becomes the coordination point.
Typical access latency ranges (order-of-magnitude):
| Access path | Approx. latency |
|---|---|
| CPU cache (L1/L2) | ~1-10 ns |
| RAM | ~50-150 ns |
| Local SSD read | ~50-200 μs |
| Redis over network | ~0.2-2 ms |
| Database read (indexed) | ~2-10+ ms |
Alt: Latency comparisons help explain why a fast, bounded Redis lock can suppress duplicates before slower systems are touched. (Values vary by workload and environment.)
We build an idempotency key for a specific “unit of work,” typically:
We usually want:
…but we still need legitimate transitions to proceed. Including status gives us “effectively-once per status” while still allowing real state changes to flow through.
At a high level, the webhook handler becomes “lock-first”. First, here’s the user-impact framing:

Alt: Without idempotency, retries can multiply user-facing side effects. With a lock, duplicates become no-ops.
Now the system view:

Alt: High-level flow, validate, acquire lock, then perform side effects. If the lock already exists, skip and return success.
The key property is that concurrent deliveries compete for the same atomic lock, and only one performs stateful work.

Alt: Only one worker acquires the idempotency lock. The duplicate delivery exits without side effects.
The implementation is intentionally simple:
🧠A useful mental model: the lock protects the most expensive and most stateful part of the handler, database writes, event publication, and any external side effects
We recommend a convention like:
servicePrefix:transferId:statusThis helps:
The TTL should be:
This keeps the system resilient: even if a lock is orphaned, it naturally expires and allows reprocessing.
What this pattern provides:
What it does not claim to provide by itself:
With duplicates suppressed at the edge, product behavior becomes more consistent:
Downstream systems also become more predictable:
Most importantly: the system’s behavior under retries becomes easier for engineers to reason about.
Even with idempotency locks, operations matter. A few practical guardrails help:
✅ If your webhook handler can safely say “I’ve already processed this exact update,” retries become a reliability feature instead of an incident source.
Written by Emerson Costa
