TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

66 点作者 abahlo超过 4 年前

6 条评论

sylvain_kerkour超过 4 年前
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 未加载
jhgg超过 4 年前
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 未加载
lmilcin超过 4 年前
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 未加载
Dowwie超过 4 年前
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.
abahlo超过 4 年前
Needed this functionality in a Rust application I&#x27;m writing so I ported the Go code to Rust.
评论 #25592545 未加载
评论 #25592428 未加载
random5634超过 4 年前
How do you use 64 bits and only get scale to 180 years? For that bit count I’d expect 1000+
评论 #25592721 未加载