Page 1 of 1

LockAndIncrement

Posted: Thu Jun 01, 2006 8:01 pm
by Peijen
How would you implement a distributed lock and increment function? Obvisouly the goal is atomic operation and speed, however given a distributed environment we have to worry about connectivity as well.

Also what other issues I should think about to make sure I am not missing anything?

Posted: Thu Jun 01, 2006 8:57 pm
by Jonathan
How many agents?

Posted: Thu Jun 01, 2006 9:59 pm
by Peijen
Don't know, let's say less than 10000.

Posted: Fri Jun 02, 2006 1:54 am
by Jason
Do you really need a lock and increment? What are you trying to track?

Posted: Fri Jun 02, 2006 2:55 am
by Peijen
Unique ID in sequence

Posted: Fri Jun 02, 2006 2:56 am
by Peijen
Actually after some though, connectivity shouldn't matter too much. If I skipped a number I skipped a number, but I want to keep it at minimum.

Posted: Sun Jun 04, 2006 5:32 pm
by Jason
Just kind of wondering, but why does the unique id have to be in sequence? Especially if you can skip a number?

I use GUIDs for everything now. It saves enormously on concurrency constraints that aren't necessary.

Posted: Mon Jun 05, 2006 4:04 pm
by Peijen
Hashing, indexing, and searching. GUID is good for hashing but not very good for indexing or searching performance wise.

Posted: Tue Jun 06, 2006 12:30 am
by quantus
Peijen wrote:Hashing, indexing, and searching. GUID is good for hashing but not very good for indexing or searching performance wise.
I think you're only trading away O(1) for O(log n) (or whatever your hash time is) for searching and indexing, which shouldn't be too bad.