Page 1 of 1

LockAndIncrement

PostPosted: Thu Jun 01, 2006 7: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?

PostPosted: Thu Jun 01, 2006 7:57 pm
by Jonathan
How many agents?

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

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

PostPosted: Fri Jun 02, 2006 1:55 am
by Peijen
Unique ID in sequence

PostPosted: Fri Jun 02, 2006 1: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.

PostPosted: Sun Jun 04, 2006 4: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.

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

PostPosted: Mon Jun 05, 2006 11:30 pm
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.