Torquebox – When Ruby Meets Enterprise

Episode 1 – Introduction to Torquebox

This episode is part of a series aiming at introducing Torquebox, from development setup to production deployment. New articles will be posted every week.


As an engineer using Ruby for web development, you’re used to get pretty much everything out of the box: Rails gives you the fastest way to bootstrap your web application, Devise and OmniAuth will give you user/sso management, Geocoder provides geolocation in a tick, Open Exchange Rates enables currency conversion, Stripe gives you a payment gateway etc.

Does this give us everything? Well, not completely. You will come at a point where you actually need more than just libraries or services. You’ll definitely need to implement and scale background jobs, queues, caching systems and that’s where things may become time consuming, messy and/or expensive. You’ll start implementing DelayedJob or Sidekiq for managing background processes, Memcached for distributed caching and potentially ActiveMQ/RabbitMQ or Resque for queues/processors. All of this comes on top of scaling managing your own Rails application server of course (and database).

There is another way. If you’re like me and like to get everything out of the box then you’ll find yourself a new friend: Torquebox.

Torquebox? Quezako?


You may have heard of a crazy company releasing Enterprise Open Source products called Red Hat.

Amongst the widely popular products they developed – such as RedHat Enterprise Linux (RHEL) – is JBoss Application Server (JBoss AS). JBoss AS is a fully featured Java Application Server bundling everything you need to manage your application:

–       Web Server

–       Scheduled/Background Jobs – using Quartz

–       Queues/Processors – using HornetQ

–       Caching – using Infinispan

–       Automated Clustering and Discovery – using jGroups

Yes, all of that at once. Once configured, every component scale as you scale your JBoss cluster. By default, there is no need to scale each of them separately….and that’s definitely a time saver! Individual component scaling is still possible if you require it.

So what? Do I just switch my app to Java and start using JBoss. Well you could but that’s not the plan here. I love the JVM but definitely prefer to use Ruby.

Here comes Torquebox!

Torquebox is an awesome JRuby middleware allowing you to deploy your Ruby application on top of JBoss AS. It also provides very simple interfaces to each of the components offered by JBoss AS: queues, background jobs, caching etc.


If you have a Rails application, you can pretty much port it to JBoss straight away without doing anything special, thanks to Torquebox. (Note: if you are already using background jobs, you will need to rework that part).

“Enough teasing. Show me the good stuff.”


Features in action

For the purpose of demonstrating the features of Torquebox, we’ll suppose that we have a blogging application built using Rails.

Queues & Message Processing

Let’s say our application allows users to comment on blog posts. We want to verify the comments before displaying them. Here is how we would do it asynchronously using Torquebox:

Recurring Jobs

Let’s say we want to regularly update our blog statistics with the most commented blog post over the last 7 days. Well, we could just do something like this using Torquebox:


If using Rails, nothing special is required. Rails caching interface is automatically configured to use Infinispan by default.

Caching the most recent 50 blog post comments in your PostsController becomes extremely easy:


The bonus part with Torquebox is performance, for two reasons:

  1. Because you’re using jruby and the JVM
  2. Because Torquebox is a damn good server!


Want to see a benchmark? Here is the one that was published by the Torquebox team when they released Torquebox 4:


Original publication

Note: I’m will not enter into the JRuby vs MRI Ruby vs Rubinius performance debate. You will find various benchmarks on the web showing that each of them is a winner depending on the use case, the ruby version, the implementation version and the date of publication. The most recent one I found is:, giving JRuby winner in this case. JRuby gave us very good performance and that’s what really matters.


The goal of this article was really just to introduce you to Torquebox and showing you the high level features it offers.

Next week we will dig a little deeper and cover how to setup your development environment, using a Rails 4 application as an example. Installation and configuration, Unit Testing, Performance Testing, Runtime monitoring etc. We’ll cover all the basics.


Some useful links about Torquebox.

Torquebox Home:

TQ 3 Documentation:

TQ 3 Getting Started Guide:

TQ 4 Documentation:

TQ Example apps:

A simple yet concrete example from one of Maestrano engineers, Bruno:

Arnaud Lachaume