6

I'm building a Rails 3 application that I plan on provided as a subscription-based SaaS (Software as a Service) product. Basically, I want users to be able to hit my "Sign up" page, create a new account, and immediately start using the software.

A good example of what I'm trying to accomplish is: http://www.getharvest.com/

Here's what I need to happen when someone signs up:

  1. A MySQL database for them is generated on the db server
  2. A sub-domain is created (e.g., companyx.awesomeapp.com)
  3. The Rails app should know the appropriate database to connect to based on the sub-domain

Are there any good guides out there for setting this stuff up? Even better, are there services that you can purchase to automate this type of thing? Ideally, I'd like to just worry about writing my Rails app and then be able to plop it atop some awesome Rails SaaS infrastructure.

(Also, I need a way to bill them monthly, but I think that's a separate question/problem.)

Finch
  • 1,741
  • 3
  • 15
  • 15
  • 1
    I don't mean to offend you but things like creating sub domains and databases on a MySql server are kinda basic. Perhaps you should read up on the technologies that you plan to use before you try programming for them. It would save you a lot of frustration down the road. – Devin M Aug 05 '11 at 19:45
  • @Devin Right. I know how to do all this stuff manually. I could even roll my own set of scripts to automate the process. I'm wondering if there's a pre-built infrastructure for this type of thing that I could plug my Rails app into. – Finch Aug 05 '11 at 19:54
  • Your looking at Heroku, Amazon Web Services or Softlayers CloudLayer. And if all you want to do is something like GetHarvest I dont see why this needs to be so complex. You should only need one database and subdomains can be managed by the application using a catchall DNS record. – Devin M Aug 05 '11 at 20:04
  • The way the app is built, it's one account per database. For example, the `Users` table is populated with users your *your* account. I could change all of the tables to have an `account_id` field and modify the app to always query based on that, but it's kinda too late for that :-). – Finch Aug 05 '11 at 20:18
  • 1
    Hmm. Multi-tenancy seems **super** easy in Rails. It might be worthwhile to rethink the app. Found this: http://samuel.kadolph.com/2010/12/simple-rails-multi-tenancy/ – Finch Aug 05 '11 at 20:22
  • Multi-Tenancy is the way to go, I would evaluate the hardware/hosting costs compared to the costs of refactoring. – Devin M Aug 05 '11 at 20:24

1 Answers1

1

Heroku would let you get up and running quickly. You can manage the infrastructure using the heroku gem. Here is the documentation to the client which should allow you to manage heroku applications remotely. Using heroku would allow you to scale applications on an individual level and let you focus on the code of the application instead of the hardware.

Devin M
  • 9,636
  • 2
  • 33
  • 46
  • Thanks! Looks like Heroku might be the way to go. If I have it correct, anytime someone signs up, all I have to do is deploy a new instance of my Rails app to Heroku with a different subdomain and I'm done. – Finch Aug 05 '11 at 20:15