||The neutrality of this article is disputed. (May 2012)|
|Original author(s)||Philotic, Inc|
|Stable release||1.8 / November 3, 2012|
|Operating system||Linux, Windows, Mac OSX|
Beanstalk is a simple, fast work queue. Many web applications have some slow tasks that could be done in the background like sending emails, processing statistics, creating files, etc. One rule of thumb is that if a request takes more than a few seconds to process, it would be advisable for the developer to turn it into a background process, so that a response can be returned to the web browser without waiting for the longer process to finish. That's where beanstalkd comes in.
Its interface is generic, but was originally designed for reducing the latency of page views in high-volume web applications by running time-consuming tasks asynchronously.
Philotic, Inc. developed beanstalk to improve the response time for one of their projects, a Facebook app called Causes, which had over 9.5 million users. Using beanstalk helped them decrease the average response time for the most common pages to a tiny fraction of the original, thus significantly improving the user experience.
Beanstalk'd is a simple text-based protocol. One application (a producer) adds messages or jobs to a queue, that can then be run with worker processes (or consumers). The producers and consumers can be on the same machine, or on different machines. The queue can be persistent by saving to a file, and most of its clients support connections to multiple beanstalkd servers. Central to beanstalk is the concept of tubes. Tubes are independent job queues, somewhat like database tables. A queue can have several tubes at one time. Once a job is processed by worker it can be deleted permanently or "buried" (accessible only by a "kick"). Typically a job would be buried when it fails to complete; a "kick" is a manual retry of the job, hopefully after resolving whatever problem caused it to fail the first time. It is simple enough for most web apps.
beanstalkd [OPTIONS] Options: -d detach -b DIR binlog directory -f MS fsync at most once every MS milliseconds (use -f 0 for "always fsync") -F never fsync (default) -l ADDR listen on address (default is 0.0.0.0) -p PORT listen on port (default is 11300) -u USER become user and group -z BYTES set the maximum job size in bytes (default is 65535) -s BYTES set the size of each binlog file (default is 10485760) -v show version information -h show this help
- Eliminating long-running Cron jobs
- Parallel and/or asynchronous work
- Scales easily - run more workers