public
Description: Utilities and Algorithms for Distributed Processing.
Homepage:
Clone URL: git://github.com/mperham/politics.git
mperham (author)
Thu Feb 05 08:45:53 -0800 2009
commit  2aa5b7edfe9307d18f35c102def7a696b11cbc53
tree    3a5c4596ac3d57f1362de5435aa40c137f80304f
parent  38a432af969d986dd896df7c2844e904394a68b5
name age message
file History.rdoc Loading commit data...
file LICENSE Mon Oct 06 19:11:12 -0700 2008 Prepare for 0.1 release [mperham]
file Manifest Tue Oct 28 14:55:53 -0700 2008 Add static queue worker example Update gemspec ... [mperham]
file README.rdoc Thu Jan 01 10:58:09 -0800 2009 Remove old url [mperham]
file Rakefile Mon Nov 03 19:13:29 -0800 2008 Release 0.2.1 gem [mperham]
directory examples/ Mon Nov 03 19:05:37 -0800 2008 Add StaticQueueWorker example [mperham]
directory lib/
file politics.gemspec
directory test/
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.