Python implementation of Twitter's Snowflake Unique ID generation service
Python Thrift Shell
Switch branches/tags
Nothing to show
Clone or download
Latest commit bdcf5a0 Jul 8, 2017



pysnowflake is a Python implementation of Twitter's snowflake service -

I implemented it in pure Python using the same thrift interfaces because I really dislike the whole overhead the Java Runtime brings with it. Not to mention the fact that its really hard to run it on small servers with little RAM because you have to fine tune it to the right memory amounts.

With Python its easier and quicker to setup.

Due to various reasons this implementation does not reach the performance indicated in the original Snowflake implementation, however it is good enough in most cases and can be combined with the help of a software load balancer such as HAProxy to run multiple processes to get higher performance.

You can checkout a Python client implementation I did which I use with this server at:


  • Make sure you have the Thrift Python libraries (0.61 and above would be great)
  • Run the service


usage: [-h] [--host HOST] [--port PORT] [--log_level LOG_LEVEL] [--verbose] worker_id data_center_id

Python based Snowflake server

positional arguments: worker_id Worker ID data_center_id Data Center ID

optional arguments: -h, --help show this help message and exit --host HOST Host address (default --port PORT port (default 30303) --log_level LOG_LEVEL Log level (default: INFO). Values: ERROR,WARN,INFO,DEBUG --verbose Be verbose!

Running it

./pysnowflake worker_id data_center_id (i.e. ./pysnowflake 1 1)



Please report any issues via github issues