TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Sonyflake – distributed unique ID generator implemented in Rust

66 pointsby abahloover 4 years ago

6 comments

sylvain_kerkourover 4 years ago
After a lot of time spent investigating the different kind of (U)UIDs, I&#x27;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:&#x2F;&#x2F;github.com&#x2F;ulid&#x2F;spec" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ulid&#x2F;spec</a>
评论 #25594657 未加载
评论 #25594449 未加载
评论 #25594090 未加载
评论 #25595199 未加载
评论 #25594060 未加载
评论 #25597471 未加载
jhggover 4 years ago
Discord uses snowflake based IDs to great success. It&#x27;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.
评论 #25602723 未加载
lmilcinover 4 years ago
Unfortunately, 8 bits for sequence for each 1&#x2F;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.
评论 #25593688 未加载
评论 #25593940 未加载
评论 #25596073 未加载
Dowwieover 4 years ago
Before starting this, did you look at the flaken crate? If so, any concerns or notable differences? <a href="https:&#x2F;&#x2F;github.com&#x2F;bfrog&#x2F;flaken" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bfrog&#x2F;flaken</a><p>Although it hasn&#x27;t been maintained in 4-5 years, it&#x27;s not the kind of library that requires any maintenance following creation of a stable generator. Maybe someone could bench it.
abahloover 4 years ago
Needed this functionality in a Rust application I&#x27;m writing so I ported the Go code to Rust.
评论 #25592545 未加载
评论 #25592428 未加载
random5634over 4 years ago
How do you use 64 bits and only get scale to 180 years? For that bit count I’d expect 1000+
评论 #25592721 未加载