Installing Beanstalkd queing daemon on Mac OS X

August 28, 2009 · 0 comments

in How To Articles About Web Application Deployment

Beanstalkd is a queueing deamon that let’s you queue messages from one client and let them be processed by another client. It has features like burrying messages for later usage if the command at the first time can’t be executed and more stuff like that.

We use it for queuing things in Ruby on Rails applications which are time-intensive. For example, executing an install command on a remote server can take some time and you don’t want your web application to block or queue op other requests in this case.

Beanstalkd has excellent Ruby bindings which you can use in  your Rails app. There’s even a gem for it:

gem install beanstalk-client

Using it is as easy as:

beanstalk = Beanstalk::Pool.new(['10.0.1.5:11300'])
beanstalk.put('hello')

beanstalk = Beanstalk::Pool.new(['10.0.1.5:11300'])
loop do
  job = beanstalk.reserve
  puts job.body # prints "hello"
  job.delete
end

Installing on Mac OS X

Beanstalkd depends on libEvent, so you’ll need to install that first:

wget http://monkey.org/~provos/libevent-1.4.12-stable.tar.gz
tar zxvf libevent-1.4.12-stable.tar.gz
cd libevent-1.4.12-stable
./configure
make
sudo make install

And then you can install Beanstalkd:

wget http://xph.us/dist/beanstalkd/beanstalkd-1.3.tar.gz
tar zxvf beanstalkd-1.3.tar.gz
cd beanstalkd-1.3.tar.gz
./configure
make
sudo make install

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post:

Next post: