I forked the code that Ryan King wrote for Twitter called snowflake.
Snowflake works by guaranteeing a unique user id based on a few simple guarantees: time, machine id and sequence number.
My fork has a fix for the ruby client allowing you to query multiple servers.
Here are the prerequisites:
- Java 6 (1.6)
- sbt (simple-build-tool) – http://code.google.com/p/simple-build-tool/
- thrift – http://incubator.apache.org/thrift/
The install process is fairly straightforward:
- Clone the repo: git clone http://github.com/twitter/snowflake.git
- Edit project/build.properties to use sbt.version=0.7.4
- sbt update
- sbt compile
- sbt test
- Copy one of the configs into /etc: cp config/development2.conf /etc/unknown.conf Or you can also just use ‘sbt run -f config/development2.conf’.
- Edit the conf and add a unique worker ID: worker_id = 1
- In the conf: skip_sanity_checks = false
- sbt run
When you run the client like so:
RUBYLIB=./target/gen-rb ./src/scripts/client_test.rb 1 “192.168.0.103:7610,192.168.0.109:7610” test-on
You should get something like this:
557299556602089472 test-on 1
Leave a Reply