See this amazing article by Martin Kleppman, author of Designing Data-Intensive Applications.
"How to do distributed locking"
https://martin.kleppmann.com/2016/02/08/how-to-do-distribute...