LockAndIncrement

Posts you want to find years later go here.

LockAndIncrement

Postby Peijen » Thu Jun 01, 2006 7:01 pm

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?
Peijen
Minion to the Exalted Pooh-Bah
 
Posts: 2778
Joined: Fri Jul 18, 2003 1:28 pm
Location: Irvine, CA

Postby Jonathan » Thu Jun 01, 2006 7:57 pm

How many agents?
Jonathan
Grand Pooh-Bah
 
Posts: 6017
Joined: Tue Sep 19, 2006 7:45 pm
Location: Portland, OR

Postby Peijen » Thu Jun 01, 2006 8:59 pm

Don't know, let's say less than 10000.
Peijen
Minion to the Exalted Pooh-Bah
 
Posts: 2778
Joined: Fri Jul 18, 2003 1:28 pm
Location: Irvine, CA

Postby Jason » Fri Jun 02, 2006 12:54 am

Do you really need a lock and increment? What are you trying to track?
User avatar
Jason
Veteran Doodler
 
Posts: 1518
Joined: Thu Jul 17, 2003 11:53 pm
Location: Fairfax, VA

Postby Peijen » Fri Jun 02, 2006 1:55 am

Unique ID in sequence
Peijen
Minion to the Exalted Pooh-Bah
 
Posts: 2778
Joined: Fri Jul 18, 2003 1:28 pm
Location: Irvine, CA

Postby Peijen » Fri Jun 02, 2006 1:56 am

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.
Peijen
Minion to the Exalted Pooh-Bah
 
Posts: 2778
Joined: Fri Jul 18, 2003 1:28 pm
Location: Irvine, CA

Postby Jason » Sun Jun 04, 2006 4:32 pm

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.
User avatar
Jason
Veteran Doodler
 
Posts: 1518
Joined: Thu Jul 17, 2003 11:53 pm
Location: Fairfax, VA

Postby Peijen » Mon Jun 05, 2006 3:04 pm

Hashing, indexing, and searching. GUID is good for hashing but not very good for indexing or searching performance wise.
Peijen
Minion to the Exalted Pooh-Bah
 
Posts: 2778
Joined: Fri Jul 18, 2003 1:28 pm
Location: Irvine, CA

Postby quantus » Mon Jun 05, 2006 11:30 pm

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
User avatar
quantus
Tenth Dan Procrastinator
 
Posts: 4648
Joined: Fri Jul 18, 2003 2:09 am
Location: San Jose, CA


Return to The Vault

Who is online

Users browsing this forum: No registered users and 1 guest

cron