Skip to content
This repository

Distributes the running of a commands across a pool of brokers and workers

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 bin
Octocat-spinner-32 lib
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 Procfile
Octocat-spinner-32 README.md
Octocat-spinner-32 composer.json
Octocat-spinner-32 composer.lock
README.md

Testcloud

Note: 99designs stopped using testcloud April 2014

Testcloud allows for the distributed execution of commands (typically processing heavy), and aggregates the results on the calling client.

Much like xargs or gnu parallel, it reads commands to execute from STDIN and runs them in parallel across a cloud of workers, either local or remote.

Install

Before you install testcloud, install PHP 5.3.1+, zeromq and the php zeromq binding:

$ aptitude install libzmq-dev
$ pear channel-discover pear.zero.mq
$ pecl install zero.mq/zmq-beta
$ echo "extension=zmq.so" >> /etc/php.ini

The recommended way to install testcloud is through composer.

$ php composer.phar create-project 99designs/testcloud /usr/local/testcloud
ln -s /usr/local/testcloud/bin/* /usr/local/bin

Example

Here is an example of a distributing the calculation of PI to several decimal places:

$ testbroker &
$ testworker &
$ seq 5 | awk '{print "bin/pi " $1}' | testcloud

The results are:

Connecting to tcp://localhost:2224
OK! bin/pi 1 ⌚8.14ms
2.8

OK! bin/pi 2 ⌚7.58ms
3.12

OK! bin/pi 3 ⌚7.74ms
3.140

OK! bin/pi 4 ⌚7.73ms
3.1412

OK! bin/pi 5 ⌚9.72ms
3.14156

All commands successfully executed ☃
Ran 5 commands in ⌚0.05s, result hash is 24aa911ac6e5f453c2ca1fa3cd8fe3ad2d6b1f43

Protocol

Testcloud is made up of workers, brokers and clients. Workers take jobs and synchronously execute them, returning results in JSON. Brokers bind on two points, one for downstream workers (or other brokers) and one for upstream workers.

A conversation below shows a broker and worker starting up:

worker -> broker: RDY
client -> broker: {"cmd":"pi 1"}
worker -> broker -> client: QUE 9f84903
worker -> broker -> client: WRK 9f84903
worker -> broker -> client: WRK 9f84903
worker -> broker -> client: RES {"hash":"9f84903","exit":0,"stdout":"3.12\n","time":13.95}
worker -> broker: RDY

A worker sends READY when it needs jobs, WORKING whilst it's doing them and RESULT when it's done. When a worker isn't processing work, it should periodically send new READY commands.

A worker might also send NFI if it doesn't have the passed working directory, or WTF with a terminal error.

Architecture

Testcloud aims to provide a robust networking topology for distributing tasks. The client and worker are designed to be relatively dumb, with the majority of retry and error handling encapsulated in the broker.

The architecture supports cascading brokers to brokers via testbroker --upstream tcp://anotherbroker:2225.

License

MIT, see LICENSE.

Something went wrong with that request. Please try again.