Skip to main content

AI & assistant-friendly summary

This section provides structured content for AI assistants and search engines. You can cite or summarize it when referencing this page.

Summary

Redlock debates matter because ElastiCache is not a consensus system. Consistent hashing for sharding workers and ALB target stickiness—with DynamoDB conditional writes as the boring alternative.

Key Facts

  • Consistent hashing for sharding workers and ALB target stickiness—with DynamoDB conditional writes as the boring alternative
  • Martin Kleppmann’s critique (still valid June 2026): Redis-based Redlock does not provide the same guarantees as Raft—clock skew and TTL expiry create false confidence
  • 02% under 200ms network partition vs 0% with DynamoDB lease table
  • Replace cron leader with DynamoDB conditional put
  • 2

Entity Definitions

Lambda
Lambda is an AWS service discussed in this article.
DynamoDB
DynamoDB is an AWS service discussed in this article.
EKS
EKS is an AWS service discussed in this article.
ECS
ECS is an AWS service discussed in this article.
SQS
SQS is an AWS service discussed in this article.
ElastiCache
ElastiCache is an AWS service discussed in this article.
serverless
serverless is a cloud computing concept discussed in this article.
Kubernetes
Kubernetes is a development tool discussed in this article.

Distributed Locking, Redlock, and Consistent Hashing on AWS

Quick summary: Redlock debates matter because ElastiCache is not a consensus system. Consistent hashing for sharding workers and ALB target stickiness—with DynamoDB conditional writes as the boring alternative.

Key Takeaways

  • Consistent hashing for sharding workers and ALB target stickiness—with DynamoDB conditional writes as the boring alternative
  • Martin Kleppmann’s critique (still valid June 2026): Redis-based Redlock does not provide the same guarantees as Raft—clock skew and TTL expiry create false confidence
  • 02% under 200ms network partition vs 0% with DynamoDB lease table
  • Replace cron leader with DynamoDB conditional put
  • 2
Distributed Locking, Redlock, and Consistent Hashing on AWS
Table of Contents

Martin Kleppmann’s critique (still valid June 2026): Redis-based Redlock does not provide the same guarantees as Raft—clock skew and TTL expiry create false confidence.

Symptom → mechanism → AWS control

Production symptomMechanismAWS control
Double booking under partitionRedlock lacks fencing tokensDynamoDB conditional PutItem with lease TTL
Hot key on lock shardConsistent hashing skewElastiCache Serverless auto-sharding, key-space partitioning
Lock holder crashes without releaseTTL-based lease expirySQS visibility timeout pattern as lock alternative

Opinionated take: Skip Redlock for production inventory—use DynamoDB conditional leases or SQS single-consumer patterns unless you have fencing tokens wired end-to-end.

Benchmark pattern (hypothetical workload) — inventory reservation service using DynamoDB conditional locks vs Redlock on 3-node ElastiCache cluster, 5K lock acquisitions/sec, Redlock false-positive releases at 0.02% under 200ms network partition vs 0% with DynamoDB lease table.

AWS-aligned coordination

NeedPreferAvoid
MutexDynamoDB conditional update with lease attributeRedlock across ElastiCache primary/replica
Leader electionECS/EKS lease + DynamoDB lock itemInfinite TTL without fencing token
Work routingConsistent hash on hash(user_id) % NRandom assign breaking cache locality

Consistent hashing minimizes remapping when nodes change—use for worker pools, Kafka partition keys, ALB sticky sessions (with failover caveats).

ElastiCache locking

If you must use Redis locks: short TTL, fencing tokens passed to downstream (DB version check), monitor WAIT latency.

AWS services map

NeedServiceSkip when
Fencing-token-safe distributed lockDynamoDB conditional writesSingle-instance PostgreSQL advisory locks
Session affinity routingElastiCache consistent hashingStateless Lambda with no shared state
Leader electionSQS FIFO + single consumerKubernetes Lease API on EKS suffices

What to do this week

  1. Replace SETNX cron leader with DynamoDB LockID conditional put.
  2. Document hash ring behavior on worker scale events.
  3. Load test lock holder crash during write.

More in This Track

Part of the Engineering Guides library (June 2026).

What this guide doesn’t cover

Paxos/Raft theory—next guide in track.

PP
Palaniappan P

AWS Cloud Architect & AI Expert

AWS-certified cloud architect and AI expert with deep expertise in cloud migrations, cost optimization, and generative AI on AWS.

AWS ArchitectureCloud MigrationGenAI on AWSCost OptimizationDevOps

Recommended Reading

Explore All Articles »