LockAndIncrement

Posts you want to find years later go here.
Post Reply
Peijen
Minion to the Exalted Pooh-Bah
Posts: 2790
Joined: Fri Jul 18, 2003 2:28 pm
Location: Irvine, CA

LockAndIncrement

Post 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?

Jonathan
Grand Pooh-Bah
Posts: 6718
Joined: Tue Sep 19, 2006 8:45 pm
Location: Portland, OR
Contact:

Post by Jonathan »

How many agents?

Peijen
Minion to the Exalted Pooh-Bah
Posts: 2790
Joined: Fri Jul 18, 2003 2:28 pm
Location: Irvine, CA

Post by Peijen »

Don't know, let's say less than 10000.

Jason
Veteran Doodler
Posts: 1520
Joined: Fri Jul 18, 2003 12:53 am
Location: Fairfax, VA

Post by Jason »

Do you really need a lock and increment? What are you trying to track?

Peijen
Minion to the Exalted Pooh-Bah
Posts: 2790
Joined: Fri Jul 18, 2003 2:28 pm
Location: Irvine, CA

Post by Peijen »

Unique ID in sequence

Peijen
Minion to the Exalted Pooh-Bah
Posts: 2790
Joined: Fri Jul 18, 2003 2:28 pm
Location: Irvine, CA

Post 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.

Jason
Veteran Doodler
Posts: 1520
Joined: Fri Jul 18, 2003 12:53 am
Location: Fairfax, VA

Post 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.

Peijen
Minion to the Exalted Pooh-Bah
Posts: 2790
Joined: Fri Jul 18, 2003 2:28 pm
Location: Irvine, CA

Post by Peijen »

Hashing, indexing, and searching. GUID is good for hashing but not very good for indexing or searching performance wise.

quantus
Tenth Dan Procrastinator
Posts: 4889
Joined: Fri Jul 18, 2003 3:09 am
Location: San Jose, CA

Post 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.
Have you clicked today? Check status, then: People, Jobs or Roads

Post Reply