Other posts in this series
Gearman has occupied my thoughts and time lately. Gearman is a “generic application framework to farm out work to other machines or processes that are better suited to do the work”.
In short, it’s a job-queue system. You send it jobs you want done, it delegates those tasks to workers who know how to handle that work. Workers connect to the server and announce what jobs it can handle; The server doesn’t care about “how” they handle that job, just that they can. The server passes the job off to the worker and can then (conditionally) pass messages back to the client for messages like status, completions, or failures.
Classic usage examples for websites are image resizing or video conversion. Instead of the user waiting for the server to re-size or convert, you redirect them elsewhere with a message saying it will be done soon. This lets the user go about their business, and you can delegate the work to another machine, leaving your web server to serve webpages instead hog memory converting things.
##Setup If you’re on a Mac, I highly recommend Homebrew, an excellent package manager for installing all kinds of software with ease. Getting Gearmand (the daemon process and client libraries) is easy:
If you’re using MacPorts
If you’re on Ubuntu you can use
Check your favorite Linux Distro’s package manager for their equivalent.
Finally, you can always compile from source
Once that finishes, you should have Gearman all setup
##Running Gearmand is typically run as a daemon in the background
This causes Geramand to run to detach from the current shell and run in the background. While developing, it may be helpful to run in debugging mode
By default, Geramand listens on
. There are many other options you can choose to add.