Skip to main content

Snowflake ID Toolkit - Generate distributed unique IDs.

Project description

snowflake-id-toolkit

A Python toolkit for generating snowflake-like unique IDs.

Supported Implementations

  • Twitter Snowflake - 64-bit IDs with ~69 years of timestamps, 1024 nodes, 4096 IDs per millisecond per node
  • Instagram Snowflake (coming soon)
  • Sony Sonyflake (coming soon)

Installation

pip install snowflake-id-toolkit

Usage

from snowflake_id_toolkit.twitter import TwitterSnowflakeIDGenerator

generator = TwitterSnowflakeIDGenerator(
    node_id=0,
    epoch=1288834974657  # Twitter's default epoch
)
snowflake_id = generator.generate_next_id()

Comparison with Other ID Strategies

Feature Snowflake UUIDv4 UUIDv7 Auto-increment
Size 64 bits 128 bits 128 bits 32-64 bits
Sortable by time
Distributed generation
No coordination needed ⚠️
DB Index-friendly ⚠️
Predictability Medium None Low High
Throughput ~4M/sec/node Unlimited Unlimited DB-limited
Relative speed ~5.2x ~1.1x 1x (baseline) N/A (DB-bound)

When to Use

  • Snowflake: High-throughput distributed systems needing compact, sortable IDs
  • UUIDv4: When unpredictability matters, size doesn't, and no sorting needed
  • UUIDv7: Modern default choice when simplicity is key factor and 128 bits is acceptable
  • Auto-increment: Single-database apps where simplicity wins

License

The snowflake-id-toolkit is licensed under the MIT License. See the LICENSE file for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snowflake_id_toolkit-0.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snowflake_id_toolkit-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file snowflake_id_toolkit-0.1.0.tar.gz.

File metadata

File hashes

Hashes for snowflake_id_toolkit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 78bbac35aa87c434b3d7c17496bc04a3904019768896d8b2cfa20cf6b579d7c0
MD5 069944cdd80bbfb81e01bab1c7ef85bc
BLAKE2b-256 3dadec4adc5e87a56e7d2a248646db0b4564aa29986424b19b8dae2d32f94804

See more details on using hashes here.

File details

Details for the file snowflake_id_toolkit-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for snowflake_id_toolkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea40b50b66aff8f511d66e2d4eadf2bd5aab5997d222b40498fa8c733db2a819
MD5 1fa2c2d51ad60d54978dfee3f529a550
BLAKE2b-256 a251ec3197a9e7027d58b8e5e9a5379e7b83a872ab28872935e7e7ffcd33e4fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page