Multiple customers/tenants - keeping the data separate - how?

I have found this very good thread from 2006 about multi-tenant
applications:
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/25bc6cd899318d9a/

I’m making my app available to multiple customers and right now my
strategy is:

  1. svn export code
    each customer has their own
  2. rake setup:initialize client_name
    which creates the databases and the database.yml file
  3. rake db:migrate
    which creates all tables
  4. rake setup:blank_slate customer_name
    which adds some necessary predefined data from a couple of YML files.

The problems with this setup are:

  • the memory usage
    each tenant uses their own process and that takes a lot of memory
    which is ridiculous considering that they run the same code
  • management and provisioning issues
    Updates are cumbersome and creating another app for a tenant is
    time consuming and not that automated. The whole process takes about 1
    minute. I I ddn’t check out the code it would take less than 20
    seconds.

I used before a hijack_db metod as a before_filter in
ApplicationController that switched the database depending on the
domain. I’m not sure about the performance or security of that hack.
How do you guys manage multiiple tenants and multiple databases?

On Wed, Apr 22, 2009 at 9:16 PM, Constantin G.
[email protected] wrote:

which creates the databases and the database.yml file
Updates are cumbersome and creating another app for a tenant is
time consuming and not that automated. The whole process takes about 1
minute. I I ddn’t check out the code it would take less than 20
seconds.

I used before a hijack_db metod as a before_filter in
ApplicationController that switched the database depending on the
domain. I’m not sure about the performance or security of that hack.
How do you guys manage multiiple tenants and multiple databases?

This is a great talk/video on multi-tenant application development
from Acts As Conference 2009
http://aac2009.confreaks.com/06-feb-2009-14-30-writing-multi-tenant-applications-in-rails-guy-naor.html

Andrew T.
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

“I have never let my schooling interfere with my education” - Mark Twain