Comments (4)
- Yes. You'll want the generator-id part to be "globally" (or even "universally") unique; if you have multiple instances then (be it on different hosts, or on the same host in different processes or even in the same process in different threads), then each of the instances will need an unique generator-id.
- You're correct, as long as the max ID is less than the id's generated by IdGen at that time you should be ok. You can play with the epoch date if you want to; the closer you get it to "today" the lower your ID's will be. However, once you pick an epoch you'll need to stick with it.
You can consider an epoch of 2020-01-01 or 2021-06-01 or 2021-09-01 for example, and each of these epochs the ID's will decrease (and then increase each generated ID ofcourse) and probably get closer to your current maximum ID. But the "you'll need to stick with it" goes for the entire IdGeneratorOptions
and IdStructure
. I'm not saying it's impossible but it will be a real drag to change this (for example to have more generator-id bits) later on. So make sure you've thought things through for your specific situation and requirements.
That's about alle the advice I have I guess... Feel free to ask follow-up questions if you have any. It's a lot less complicated than it seems I guess.
from idgen.
Thanks for such thorough answers/explanations! And a couple of clarification questions from my side:
- is that correct that using different "generator-id" parts is the only way to make several instances of IdGenerator to generate unique sequences of IDs?
- as far as I understand, IdGenerator have kind of "resolution" , i.e. it can generate only limited number of IDs per time period - it is 4096 per millisecond with default settings, and can be increased by changing settings, but it will still be limited, right?
Thanks again.
from idgen.
- Yes. The README explains exactly how an ID is structured and generated.
- Yes, there's always a limit. You can sacrifice some generator-id bits trading less (possible) generators for more ID's per time period: for each bit added to the sequence part you'll double the max number for the sequence for the period. You can even sacrifice some timestamp bits (but that'll decrease the resolution of your timestamp). But I'd say 4096 per millisecond is a whole lot. That's over 4 million per second per generator. With 10 generators in the system you can do 40 million ID's per second. With 1024 generators (the maximum in the default settings) you can do a theoretical of 1024 * 4096 * 1000 = 4,194,304,000 ID's per second.
You can vary the ID structure's parts (timestamp, generator-id, sequence) number of bits; but whatever you pick you'll have to live with (or you'll have to renumber your ID's or do other trickery) once you start generating and using ID's in that chosen configuration. As long as all 3 parts add up to 63 bits (and generator-id and sequence don't exceed 31 bits) you should be good to go.
from idgen.
I see, thanks a lot
from idgen.
Related Issues (20)
- Drop support for netstandard 1.1 HOT 5
- Non-generic IIdGenerator HOT 5
- Avoid spending a sign bit by using ulongs HOT 13
- Tag 3.0.3 is missing HOT 1
- Documentation about generatorId collisions when id structure changes HOT 9
- IdGen is generating 17bit Id instead of 16bit? What should we change in the method so that it generate 16 bit Id instead of 17 bit now and in the future it continuous to generate 16 bit Id? HOT 11
- Is there a way to shorten the number of digits generated for an id? HOT 5
- Handling uniqueness ID across multiple instance of same service HOT 6
- IdGenerator does not contain a definition for 'Take' HOT 1
- Consider adding IdGenerator#CreateFromDateTime HOT 5
- Public Method Comments HOT 1
- SpinWait drastically slows continous ID generation rate for small tick length HOT 10
- Could we log how often we overflow sequence IDs and have to spinwait? HOT 1
- Concurrency issues with instances scale up HOT 2
- Use dependabot to keep references up to date HOT 1
- Sequence input for CreateId() HOT 3
- IIdGenerator is registered as a singleton, but duplicate IDs are still generated HOT 4
- Debugging InvalidSystemClockExceptions HOT 15
- Is there a way to generate id from the past HOT 1
- How to use this in distributed computing ? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from idgen.