Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are some good ways to do intermachine locking?

Our server cluster consists of 20 machines, each with 10 pids of 5 threads. We'd like some way to prevent any two threads, in any pid, on any machine, from modifying the same object at the same time.

Our code's written in Python and runs on Linux, if that helps narrow things down.

Also, it's a pretty rare case that two such threads want to do this, so we'd prefer something that optimizes the "only one thread needs this object" case to be really fast, even if it means that the "one thread has locked this object and another one needs it" case isn't great.

What are some of the best practices?

like image 830
mike Avatar asked Mar 15 '10 17:03

mike


1 Answers

If you want to synchronize across machines you need a Distributed Lock Manager.

I did some quick googling and came up with: Stackoverflow. Unfortunately they only suggest Java version, but it's a start.

If you are trying to synchronize access to files: Your filesystem should already have some wort of locking service in place. If not consider changing it.

like image 99
ebo Avatar answered Oct 18 '22 16:10

ebo