• Stars
    star
    206
  • Rank 190,504 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 13 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python implementation of Twitter's Snowflake Unique ID generation service

pysnowflake

pysnowflake is a Python implementation of Twitter's snowflake service - https://github.com/twitter/snowflake

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: https://github.com/erans/pysnowflakeclient

Installation

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

Usage

usage: pysnowflake.py [-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 127.0.0.1) --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)

Requirements

Issues

Please report any issues via github issues

More Repositories

1

ec2instancespricing

Quick and dirty Python API and CLI to get EC2 instance pricing for On-Demand and Reserved Instances
Python
172
star
2

redissnowflake

Twitter's Snowflake based ID generation as a redis module
C
72
star
3

fabric-slack-tools

Tools to integrate Fabric with Slack
Python
45
star
4

gosnowflake

Twitter's Snowflake server implemented in Go
Go
32
star
5

pysnowflakeclient

Python Client for Twitter's Snowflake Unique ID Generator Service
Python
16
star
6

fabric-gce-tools

Tools to integrate Fabric with Google Compute Engine (GCE)
Python
9
star
7

flask-secure-cookie

Adds Tornado's secure cookie support to Flask
Python
8
star
8

thumbla

Image serving and manipulation
Go
7
star
9

beanstalkdcloudwatch

Script to update AWS CloudWatch with custom metric from a Beanstalkd work queue (http://kr.github.com/beanstalkd/)
Python
7
star
10

gonionoo

Go wrapper for Onionoo - Tor network status protocol (https://onionoo.torproject.org/)
Go
6
star
11

dicepass

Digital version of EFF's dice (http://eff.org/dice)
HTML
6
star
12

membase_cloudformation_template_generator

Membase CloudFormation template generator
Python
6
star
13

twitter-csharp-library

Twitter C# REST API Library (Wrapper)
C#
6
star
14

sqscloudwatchqueuecount

Script to update AWS CloudWatch with a custom metric which contains the count of an AWS SQS queue
Python
6
star
15

ec2ssh

A simple script to use EC2 Name tags to connect directly to machines
Python
5
star
16

torcontactinfoparser

Tor ContactInfo proposal (https://github.com/nusenu/ContactInfo-Information-Sharing-Specification) parser
Python
5
star
17

nsq-to-bigquery

Stream NSQ messages to Google's BigQuery using the streaming API
Go
5
star
18

fabric-aws-tools

Tools to integrate Amazon Web Services (AWS) with Fabric
Python
4
star
19

torcontactinfogenerator

Tor ContactInfo Generator
HTML
3
star
20

thriftify

Thrift Compiler as a Service
Python
3
star
21

upupaway

Up, up and Away (upupaway) a cloud upload micro service
Go
3
star
22

redisunique

RedisUnique is a Redis module to generate unique IDs
C
2
star
23

microstripe

A microservice for processing Stripe charges and subscriptions
Go
1
star
24

gooz

Go implementation of Oz Web Authorization Protocol (https://github.com/hueniverse/oz)
1
star
25

gobriteverify

Go client for Brite Verify API
Go
1
star
26

pipeline

Go based Pipeline wrappers that saves a lot of boilerplate code
Go
1
star