Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A Resque plugin for using Resque and Redis to store and process transactions between transactional and data warehouse tables.
Branch: master

Add explicit json dependency

latest commit 77062386ed
Monica McArthur authored
Failed to load latest commit information.
lib Merge pull request #1 from RevolutionPrep/rails_3
test Change readme and some comments Add explicit json dependency
LICENSE Update README for Rails 3.0
Rakefile Remove spawn hooks

Resque Data Warehouse

A Resque plugin. Requires Resque 1.9.10 or higher.

resque-data-warehouse allows you to use Redis to queue up and then Resque to process transactions on transaction-heavy tables that need to be replicated on other tables optimized for reporting.

Transactions for a given object (classname + ID) are queued up behind a Redis key, and then processed using Resque jobs. If load is low, each transaction will be processed almost immediately after it occurs; at higher loads, multiple transactions will queue up before the Resque job gets to them, and then only the cumulative result of the previous transactions will be applied to the data warehousing table, thus minimizing database load and dynamically adjusting the delay in the copy to match the current load.

This only works with Rails >=3.0; it has been tested with Rails 3.0.5.

Usage / Examples

Suppose you have a database class Transactional, that gets a lot of traffic, and you want to have a counterpart to this class, TransactionalFact, in a data warehouse. All you need to do are the following:

  • Create an ActiveRecord model named TransactionalFact, with all the instance variables you want in it.
  • Add a method to TransactionalFact named execute_transaction, which assumes that all the fields in the fact that match the original Transactional are already set, saves them, and then performs any additional logic (denormalization, etc.) to update any remaining fields.
  • Require 'resque-data-warehouse' in Transactional, and add a line "warehoused".

Very simple examples of both classes:

class Transactional < ActiveRecord::Base
  require 'resque-data-warehouse'

class TransactionalFact < ActiveRecord::Base
  def execute_transaction
    # Any additional logic here

Customize & Extend

No customizations are available right now, but some obvious ones (such as how to derive the name of the warehoused class) are likely to occur soon.


As a gem

$ gem install resque-data-warehouse

In a Rails app, as a plugin

$ ./script/plugin install git://


Thanks to resque and Redis for making this work possible.

Something went wrong with that request. Please try again.