jargon

Comparison

Distributed lockvsMutex

Distributed lock

you need only one instance across the whole fleet to run the job, so they all try to claim a key in Redis first.

Mutual exclusion coordinated through an external store shared by multiple processes. It is far weaker than an in-process lock: the holder can be paused, partitioned or garbage-collected while its lease expires, and it will not know. Safe use needs a lease plus a fencing token checked by the resource itself.

Full entry →

Mutex

you wrap the shared counter in a lock so only one thread can be inside that block at a time.

A primitive guaranteeing that only one thread executes a protected region at once. It is the simplest correct answer to shared mutable state and the easiest way to serialise your whole application by accident. Hold it for as little code as possible, and never across I/O.

Full entry →

Related comparisons