renatocron / WorkersSnowflake

A Twitter Snowflake implementation in Cloudflare Workers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WorkersSnowflake

An implementation of Twitter Snowflake in Cloudflare Workers with 42 bits for the epoch, 9 bits for the node ID and 12 bits for the sequence ID.

Possible issues

Although node IDs are generated by colo name, collisions still may occur due to the way autoscaling works if there are a lot of requests.

Cloudflare currently has 200+ datacentres, we use 9 bits for the node ID so we have a limit of 512 locations, even if Cloudflare expands above this amount it still shouldn't be an issue depending on the distribution of the clients that request Snowflakes.

About

A Twitter Snowflake implementation in Cloudflare Workers

License:Eclipse Public License 2.0


Languages

Language:JavaScript 100.0%