Posts Tagged ‘background’

BackgroundRB versus Beanstalkd

Thursday, April 24th, 2008

This seems to be a recurring problem. Sending a lot of emails from Rails is still a bit murky. You can’t really use ActiveMailer for this because when you are trying to send 12.000 emails the request does not return a respond until all the 12.000 emails are sent. This leads to confused users who click the button again, timeouts etc etc. A general mess. You could use a cron job but that does not make that much sense as you would expect the emails being send as you press a button and not when a cron job comes along. Again confused users.

What you really want is to be able to background tasks and be done with it! For this there are many options. Unfortunately. But I believe the two candidates worth looking at are:

Beanstalkd is being used on Facebook(need I say more?). BackgroundRB enjoys more attention and has recently been rewritten and thus presumably increased in quality. The first is not as tightly coupled with Rails as the latter but that can be amended with a plugin.

Then there is the matter of compiling beanstalkd… That was no fun at all. Well maybe I made it too hard for my self and I did not exactly knew how to manipulate ‘make’. But I wanted the latest version(0.11) of beanstalkd and MacPorts only had 0.9 in stock. So I downloaded the source, followed the readme and hit make. Of course that didn’t fly. I needed to point the makefile to the correct lib directory. Long story short, I did install beanstalkd through port and took the makefile from that install and patched the makefile in the source download. Here is the patched makefile. This worked like a charm! However this made me a bit concerned how up to date the packages on our Debian staging server were. It turned out that I needed to install both the dependencies and the actual beanstalkd from source. I’d prefer gems then.

For more information on beanstalkd I gladly refer to this blog post as I decided after this ordeal that I would go forward with backgroundrb. This decision was mainly based on the better logging abilities of backgroundrb and the from source install as opposed to some gems.

A parting thought; look at the footer of backgroundrb’s website. Notice the link called Ginger Ninja? Click it. I think it’s at least weird and perhaps doggy.