Skip to content

mperham/politics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Utilities and Algorithms for Distributed Processing.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages