Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Utilities and Algorithms for Distributed Processing.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 History.rdoc
Octocat-spinner-32 LICENSE
Octocat-spinner-32 Manifest
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 politics.gemspec
README.rdoc

Politics

Politics is a Ruby library providing utilities and algorithms for solving common distributed computing problems. Distributed Computing and Politics have a number of things in common: 1) they can be beautiful in theory but get really ugly in reality; 2) after working with either for a few weeks/months/years (depending on your moral flexibility) you'll find yourself intellectually devoid, a hollow shell of a man/woman/cybernetic killing machine.

So the name is to be taken tongue in cheek. Onto the real details.

Common Problems in Distributed Computing

Ruby services are often deployed as a cloud of many processes across several machines, for fault tolerance. This introduces the problem of coordination between those processes. Specifically, how do you keep those processes from stepping on each other's electronic toes? There are several answers:

  1. Break the processing into N 'buckets'. Have an individual process fetch a bucket, work on it, and ask for another. This is a very scalable solution as it allows N workers to work on different parts of the same task concurrently. See the StaticQueueWorker mixin.

  2. Elect a leader for a short period of time. The leader is the process which performs the actual processing. After a length of time, a new leader is elected from the group. This is fault tolerant but not as scalable, as only one process is performing the task at a given point in time. See the TokenWorker mixin.

Installation

sudo gem install mperham-politics -s http://gems.github.com

Dependencies

StaticQueueWorker mixin

  • memcached - the mechanism to elect a leader amongst a set of peers.

  • DRb - the mechanism to communicate between peers.

  • mDNS - the mechanism to discover peers.

TokenWorker mixin

  • memcached - the mechanism to elect a leader amongst a set of peers.

Author

Name

Mike Perham

Email

mperham@gmail.com

Twitter

twitter.com/mperham

Homepage

mikeperham.com/

This software is free for you to use as you'd like. If you find it useful, please consider giving me a recommendation at Working with Rails.

Something went wrong with that request. Please try again.