After a lot of time spent investigating the different kind of (U)UIDs, I've come to the conclusion that ULIDs[0] are the best kind of (U)UIDs you can use for your application today:<p>* they are sortable so pagination is fast and easy.<p>* they can be represented as UUID in database (at least in Postgres).<p>* they are kind of serial, so insertion into indexes is rather good, as opposed to completely random UUIDs.<p>* 48 bits timestamp gives enough space for the next 9000 years.<p>[0] <a href="https://github.com/ulid/spec" rel="nofollow">https://github.com/ulid/spec</a>
Discord uses snowflake based IDs to great success. It's actually been one of the rock solid parts of our infrastructure and the fact that time stamps are embedded in the ID are great. Every channel, message, stream, attachment, user, server, etc... gets a snowflake.<p>We originally wrote this service in Elixir but have since rewritten it in rust. Actually very similar to this crate. Maybe I should open source ours too haha.
Unfortunately, 8 bits for sequence for each 1/100th of a second is way too low.<p>I gather the person that designed this has never seen high traffic service. But for some having cap of 25.6k unique ids per second on a node is a deal breaker.
Before starting this, did you look at the flaken crate? If so, any concerns or notable differences? <a href="https://github.com/bfrog/flaken" rel="nofollow">https://github.com/bfrog/flaken</a><p>Although it hasn't been maintained in 4-5 years, it's not the kind of library that requires any maintenance following creation of a stable generator. Maybe someone could bench it.