Search code examples
ruby-on-railsdesign-decisions

Hosting multiple sites via rails - Should I use one rails instance, or many?


I am building a rails app that will host multiple archery league websites. Lets call it myarchery.com, and say I have 2 sites: billsleague.myarchery.com and jimsleague.myarchery.com.

Now when I build this I can either:

  • Have one rails app serve up the subdomains (basecamp style), sharing all models, etc, but putting an account attribute on everything

  • Set each account up with its own rails app instance

I prefer running them all in one instance - (B/C I can set their sites up immediately when they sign up, have a single login, etc). However, I wanted to see if there legit reason to run them independently.

I plan to run this on a Linode using apache/passenger, if that influences your answer


Solution

  • Using rails3, you get subdomain routing 'for free'. See http://railscasts.com/episodes/221-subdomains-in-rails-3.

    I don't see why you'd need an account attribute on everything; your normal associations should allow you to determine ownership of subobjects.

    Running multiple instances per subdomain might seem simpler, but you will pay a heavy price in maintenance. It just does not scale well.