All Articles

Gearman

Users have high expectations of web apps in terms of performance, responsiveness and tons of features. Normally, you’re only allowed two of any list of three really cool things. In the case of Web Apps, that would be true. Most will find some compromise of between performance / responsiveness and tons of features. More features usually equals less responsiveness, depending on the feature and scale.

Enter Gearman. Gearman is a queuing system that allows work to be farmed out to other servers. Most importantly, it allows for intense tasks to be queued and performed in the background. This means that when a user performs an action that could potentially take a long time (sending notification emails, updating Full Text indexes, etc), that slow task can be queued to run in the background, and the page can be sent to the user, keeping things snappy.

Gearman is pretty simple to install on Red Hat.

download gearman from server> wget [http://launchpad.net/gearmand/trunk/0.8/+d ownload/gearmand-0.8.tar.gz](http://launchpad.net/gearmand/trunk/0.8/+download /gearmand-0.8.tar.gz)

unzip and move into the directory> tar -xvzf gearmand-0.8.tar.gz> cd gearmand-0.8

Red Hat didn’t have some dependencies. The next few steps will vary depending on your *nix distro.

Install the libevent developer library.> yum install libevent-devel

Install the e2fsprogs developer library> yum install e2fsprogs-devel

configure and install> ./configure> make> make install

/** Net Gearman **/

download php extension from the pecl repo> wget http://pecl.php.net/get/gearm an-0.4.0.tgz

untar> tar -xvf gearman-0.4.0.tgz

build the extension> phpize> ./configure> make> make test> make install

Add the extension to the php.ini

[gearman]extension=gearman.so

And you’re all set!

Integration will depend on if you decide to use the php extension, and how encapsulated the code base is. I highly recommend using the pecl extension, as it provides great implementations of the client and worker. and Gearman will save you.

Published Jul 25, 2009

Thoughts on about software, tech, leadership, food and ceramics.