A Resque plugin for using Resque and Redis to store and process transactions between transactional and data warehouse tables.
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


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://github.com/Mechaferret/resque-data-warehouse.git


Thanks to resque and Redis for making this work possible.