0

We are looking for solutions for generating Ids as per the title of this question.

for clarification:

  • we are using several different SQL Servers and application servers, any of which could be generating the id
  • we do not want to use a central ID-generating service/machine
  • we do not want to use DateTimes bitwise-converted to Guids because with so many machines there is a possibility of collision.

one possible solution is to assign each machine a start position, skip, and an offset, like this answer: https://stackoverflow.com/a/7916720/175127

this could very easily be our solution, but I'm hoping that someone among you might have a more elegant solution that better addresses some of the following issues:

  • one machine might end up assigning a lot more IDs and skip far ahead of the others. We might resync all the machines to have a new start position every day to help keep them on pace with each other, but this could result in a large amount of empty, unused IDs. We wish to minimize this.

  • we wish to see if it's possible to decrease the external dependency of each machine. At start they each have to find out how many machines there are, what the start point is, and they have to decide on unique offsets. I think having some form of central control to administer these things may be unavoidable.

the best that I could think of so far is to have a central machine that distribute ranges of Ids at a time. Each other machine grabs range-blocks as needed. If the central machine goes down, then we use the start-skip-offset system as a fallback.

Got any cool ideas SO?

Community
  • 1
  • 1
HaterTot
  • 407
  • 8
  • 18
  • possible duplicate of [Unique, numeric, incremental identifier](http://stackoverflow.com/questions/643267/unique-numeric-incremental-identifier) – Ken White Jun 04 '12 at 22:24
  • Can you have each machine assign itself a GUID, and use a combination of the GUID plus a per-server IDENTITY? Do the IDs need to interleave across servers? – Joe Jun 05 '12 at 00:50
  • Assuming your systems were purchased around the same time you could try querying the Processor ID's, take a look at [this stackoverflow post](http://stackoverflow.com/questions/6491566/getting-machine-serial-number-and-cpu-id-using-c-c-in-linux) on querying the machine serial number and processor ID in C. – secumind Jun 07 '12 at 23:22

0 Answers0