DEV Community

Cover image for Distributed locks in Node.js

Distributed locks in Node.js

Bruno Paulino on July 26, 2023

Often times, you need to build a feature that requires coordinated access to a certain resource. A common use-case is around queues where jobs can ...
Collapse
 
urielsouza29 profile image
Uriel dos Santos Souza • Edited

Object atomics?
With SharedArrayBuffer to manage worker-threads/web-workers in nodeJs and web worker in browser?

hugs

Collapse
 
bpaulino0 profile image
Bruno Paulino

Hey @urielsouza29, good question.
In my case, I needed this lock to be available across servers on a cluster, so in-memory atomic operations are not sufficient given that other servers wouldn’t be able to check on the lock state.

This is why I need a distributed lock mechanism where other servers can also write and read the lock.