Beanstalk is great option if you need a fast lightweight message queue. The protocol is simple, and there are lots of examples and libraries online. (Here's a nice summary article.)
However, it does not come with a standard management UI.
Resque, a message queue built on top of Redis, has a great web management interface as part of its source base. It was implemented as a Sinatra app, that can even be embedded into a Rails app.
(See the Resque Railscast)
Being jealous of that interface, I decided to create a similar Sinatra app that can be used to manage and monitor your beanstalkd queues. The application is called beanstalkd_view, and the source code is available on github: https://github.com/denniskuczynski/beanstalkd_view
Configuration
Since beanstalkd_view is a Sinatra app it can be embedded into a Rails app. Simply mount the application in your routes.rb file:
Alternately, beanstalkd_view uses the Vegas gem, so you can start the application from the command line on an available port. Just execute the beanstalkd_view executable which will be available after executing gem install beanstalkd_view.
To configure beanstalkd_view, you have to set the ENV['BEANSTALK_URL'] with the URLs of your beanstalkd daemons.
- If mounted in a Rails app, setting this variable could be done within an initializer.
- If running from the command line, you'll currently have to edit the bin file: beanstalkd_view/bin/beanstalkd_view, which is hardcoded to the default localhost address of beanstalkd.
Features
beanstalkd_view is a simple two page application.
The index page shows the overall beanstalkd statistics: charts showing the counts of the different job types submitted and buried, and a basic form for submitting new jobs with JSON data.
A page providing specific tube statistics and actions can be accessed by clicking on a tube name at the top of the index page. This page shows the individual tube's statistics and also forms for kicking the tube, pausing the tube, and peeking at jobs.
Behavior with multiple beanstalk queues
Beanstalkd_view leverages the beanstalk-client gem to interact with the beanstalkd daemons. This library is great because it provides a ConnectionPool object to manage interacting with multiple beanstalkd daemons.
(Beanstalkd does not natively support any form of clustering, so multiple instances must be managed by the client.)
When using multiple queues:
| Actions | Behavior |
|---|---|
| Queue statistic, tube listing, and pause commands | Sent to all queue instances |
| Kick and add new job commands (put) | Sent to random queue instances |
| Peek and delete job commands (put) | Sent to each queue instance, looking for response |
Feedback
See the github page for more information.
Please send back any feedback if you find beanstalkd_view useful. Or submit pull requests on github.
0 Comments