Build1 distinct publisher2 min readUpdated
A single-node SETNX lock breaks the moment a replica gets promoted. Redlock closes that hole with five independent Redis masters, and the invoice arrives before the correctness does.
The Engineer · Build desk

Compiled by The EngineerSomething wrong?How this is made
Start with what the 30-second expiry in `SET resource:order-42 my-random-value NX PX 30000` actually covers: a client that crashes while holding the lock, which the TTL then releases on its behalf [2]. Failover is a different hole. The write lands on the master, the master dies before the key reaches the replica, the replica is promoted, and the new master has no record that anyone holds anything [3]. No amount of TTL tuning reaches that.
Redlock's answer is arithmetic. Five independent masters and a majority rule of N/2+1 mean three have to accept the SET for the lock to count [4][5][1]. Because any two majorities of five share a node [8], two clients cannot both be told yes. The tolerance you buy is two failures out of five, which is 40 percent of the fleet unreachable before the lock stops working [4]. What you cannot do is reuse the highly available Redis you already run: the five must not replicate to or coordinate with each other [4], so a primary and its replica are one node for this purpose, not two.
The acquisition loop is where the cost shows up at runtime. The client walks the instances one at a time with a short per-instance timeout so a dead node does not stall the attempt [5], then subtracts elapsed time and an allowance for clock drift from the TTL to get the validity it may actually use [6]. A node that is slow rather than dead is the expensive case: it answers, it counts toward the quorum, and it bills the difference to your working window.
Then the clocks. If one node's clock jumps forward, from a bad NTP sync, a VM pause and resume, or a manual change, that node expires the lock while the others still consider it held, and two clients believe they own it [10]. Even with all five behaving, a client that pauses long enough for its lock to expire can wake and carry on writing as though nothing happened [11]. The mitigation is a monotonically increasing token issued with every grant, which the resource compares and rejects when it is lower than one already seen [12], enforced by the database, file store or API being protected rather than by Redis [13].
That is the part to price. If your store can reject a stale token, it is already refusing the second writer, and the five masters are buying you less duplicated work rather than mutual exclusion. If it cannot, the five masters do not close the pause window either.
Follow any of these and your For You feed starts watching them — no settings page required.
Ranked by verification strength, evidence, and original report placement.
The standard mitigation is a fencing token, a monotonically increasing number returned on every grant; a write tagged with token 33 is rejected once the storage has already seen token 34.
The source states that the protected resource itself, a database, a file store or an API, must be the one enforcing the fencing token; the supplied text is cut off mid-sentence at that point.
A single Redis instance makes a fine lock for a single-process app, but once multiple services race for the same lock and that instance can fail, a naive SETNX is no longer safe.
The basic lock is SET resource:order-42 my-random-value NX PX 30000, which sets the key only if it does not exist and gives it a 30-second expiry so a crashed client does not hold the lock forever.
If the single Redis node goes down before replicating the write and its replica is promoted to master, another client can acquire the same lock because the new master never saw the key.
Redlock, proposed by Redis's creator, uses N independent Redis masters (the reference implementation uses 5) with no replication or coordination between them.
Evidence-backed comparisons of source perspectives and observed adoption signals. Read the methodology
Which Builder, Operator, and Investor concerns the observed source mix emphasized—not a truth score.
Evidence, demonstrated adoption, hype gap, incentives, and confidence are assessed independently, each on its own current evidence. How these are measured.
Coherent single-source explainer, no external corroboration
Every claim traces to one dev.to article. The technical content is self-consistent and checkable against the algorithm it describes — command semantics, quorum arithmetic, the Lua compare-and-delete, the fencing-token sequence — and it surfaces the known critique rather than hiding it. But there is one publisher, no benchmark, no incident report and no second implementation account, and the supplied body is truncated mid-argument, which caps how far the evidence can carry.
No adoption or deployment evidence supplied
The cluster contains no release, deployment, usage disclosure, benchmark or incident data. The source is an explanatory tutorial about an existing algorithm and reports no user counts, production rollouts or measured outcomes, so adoption cannot be scored without inventing facts.
Slightly understated relative to its own claims
The source deliberately deflates its subject: it calls Redlock best-effort, states plainly that it reduces but does not eliminate the probability of a broken lock, routes correctness locks to consensus systems, and insists the protected resource must enforce fencing tokens. Cluster framing centres the cost of five masters rather than a breakthrough. Slightly negative rather than zero because the caveats are foregrounded, but the score stays near alignment since no adoption evidence exists to test any claim against.
Low: educational cross-post with self-referral, no vendor stake evident
The only incentive visible in the supplied material is authorship and distribution: the piece is published on dev.to and closes with 'Originally published at https://cslant.com/tips/distributed-locking-with', a canonical link back to the author's own site, which is a mild audience-acquisition motive. No sponsorship, vendor affiliation, product being sold, or funding relationship appears anywhere in the cluster, and the article recommends non-Redis alternatives for correctness-critical locks, which cuts against a promotional read.
Moderate-low: sound mechanics, single publisher, no adoption signal
Confidence in the algorithmic mechanics is reasonably high because they are internally consistent and arithmetically checkable, but the cluster is one publisher deep, contains no measurable adoption or outcome data, and the supplied body terminates mid-sentence in the section carrying its most consequential guidance. That combination holds overall confidence below the midpoint.
build
Two workers, one limit: a rate limiter's storage adapter is its outage policy1 distinct publisher
build
Two half-opens are not one state: the ABA bug that gated breakwater 1.01 distinct publisher
build
The 680 MB database that was really a 17 GB disk: self-hosted support platforms fail at month six1 distinct publisher
build
SSE is 30 lines on one pod. The second pod is where the engineering starts1 distinct publisher
Distinct publishers with included, body-backed reporting in this cluster.
dev.to
1 article · August 23, 2026