hderms / Snowdrift

Server to generate IDs using the same ideas as Twitter's (defunct) Snowflake project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Snowdrift

Heavily borrows from the ideas in the (unfortunately defunct) Twitter Snowflake project.

Details

id is composed of:

  • time - 41 bits (millisecond precision from UNIX epoch, not very useful currently)
  • configured machine id - 10 bits - gives us up to 1024 machines
  • sequence number - 12 bits - rolls over every 4096 per machine (with protection to avoid rollover in the same ms)

Why?

I always thought it was a really awesome idea for a project and wanted to see how fast I could get it to run in Rust. On my computer:

./hey -c 500 -z 10s http://localhost:3000/

yields 144558.9811 req/s. This would imply the max scalability for a distributed set of Snowdrift nodes would be 148M IDs generated per second.

About

Server to generate IDs using the same ideas as Twitter's (defunct) Snowflake project

License:MIT License


Languages

Language:Rust 100.0%