After playing around with AP4R, the new kid on the asynchronous Ruby block, for a little while, I held a small presentation at last week's meeting of the Ruby User Group Berlin. While it is more of an introduction than a field report I put up the slides as PDF anyway.

One note on the load balancing though. That's the issue that brought up some questions I couldn't answer, so I had another look at the documentation (which is still rather sparse, by the way.

AP4R knows two kinds of balancing. The first one is the distribution of dispatching tasks over a number of threads. That way the messages in the server's queue can be handled in parallel. Since the threads only scale on one host this doesn't allow for load balancing on several hosts.

For this AP4R has an experimental feature called carriers. These allow for the AP4R server to redistribute the messages to a bunch of servers exclusively dealing with the messages. It should be added though that these carriers use polling to fetch new messages from the master server's queue. This has the clear advantage that new carriers can be added without changing any configuration on the other servers. Carriers aren't considered stable yet, but they point in the right direction.

As for the client, let's say a Rails application, it can only handle exactly one AP4R server to transmit its messages to. So if you're balancing your application's load over several servers, you can either send all the messages to one server or have each application deliver them to its own AP4R server. The downside of this is that if one server fails, one or all of your server can't deliver asynchronous messages. So it's probably best to always rely on store-and-forward to ensure that your messages won't get lost.

For some further information I'd recommend checking out the website, the "Getting Started" document, where they show how to set up the example application, and a large set of slides from a presentation at this year's RubyKaigi.

I'm looking forward to seeing what's next for AP4R. It's a promising start.

Tags: rails, ruby
Tags: links, miscellany
  1. Integrating Ferret, a very nice search engine for Ruby, in a project with acts_as_ferret.
  2. Learning ten finger typing.
  3. Writing an article about one of my favorite clothing labels, New Zealand based Huffer, for the magazine of two friends.
  4. Been hiking though snowy mountains in Norway on my summer holiday.
  5. Reading "RESTful Web Services" by Leonard Richardson and Sam Ruby. A highly recommended book on REST which I'm starting to like.
  6. Doing my first real-life project with the features of Java 5. That might sound a little ridiculous, but the clients using Java I worked for over the last year all used Java 1.4, mainly for political reasons or restrictions of the application server environment (WebLogic 8.2 is a no-go with Java 5).
  7. Finding more and more joy in photography, and at the same time starting to really like Lightroom.
  8. Playing with AP4R, an asynchronous job processor for Ruby and Rails. It looks like a very nice and more reliable way to do background tasks than BackgrounDRb. The latter now has a new maintainer by the way. Maybe that will bring the mostly stalled development back up to par.
  9. Working in my office. Something I really enjoy. Having a decent and quiet place to work in is important for a freelancer.
  10. Looking for a new mobile. In case you're wondering the iPhone doesn't appeal to me.