Let's get some background information out of the way.
I'm working on a new application, and am using crazy new things that I haven't had a chance to really use before. Rails 3, MongoDB, Redis and Resque, HTML5, etc. 1
With all these things, I figured I'll just use EngineYard since I can pretty much do whatever I want with the server, and they have a lot of the "stuff" taken care of. But they don't support MongoDB out of the box, and you have to some magic with chef scripts, and then to keep your Resque workers running, you need to write stuff for that too, and so on.
I did that originally, but frankly, I'd rather be working on my app than the infrastructure.
Heroku to the rescue
As you might know, I'm a big fan of Heroku. This blog runs on it, and I don't have to ever think about it. It. Just. Works.™
Now, there's nothing wrong with EngineYard, but I want to deal with as little infrastructure crap (or at least the boring parts) as possible, and Heroku lets me do that. Plus, I get some things for free, like NewRelic RPM.
redistogo
Along comes redistogo with their Heroku integration (for beta users, which I am) and a blog post on how to use Resque with Heroku. What, what, what? You can just alias the rake task and Heroku's system doesn't know the difference. Oh Em Gee.
My wife has been quite adamant about the money2
This app I'm working on, I'm hopefully going to have to pay for at some point, as I hope enough people will want to use it that the free stuff from Heroku just won't cut it. However, the less I can pay the better, and background job workers aren't free on Heroku. They are, fortunately, billed by the second.
So let's get some auto-scale up in this bitch shall we?3
First off, grab my fork of resque. I added after_enqueue
hook support, which is needed for the auto-scaling.4
Update: Chris Wanstrath pulled in my changes, so any version of resque 1.10 or higher has after_enqueue
support.
You can use this in a Gemfile
like so: