This package is abandoned and no longer maintained. No replacement package was suggested.

Distributes the running of commands across a group of workers connected via a broker

dev-master 2014-04-17 23:43 UTC


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.


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


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

OK! bin/pi 2 ⌚7.58ms

OK! bin/pi 3 ⌚7.74ms

OK! bin/pi 4 ⌚7.73ms

OK! bin/pi 5 ⌚9.72ms

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


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.


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.