2

I'm a developer trying to determine the best way to approach a rails app. I need to provide some options for deployment and am trying to minimize both development costs and long term hosting costs.

Consider a site that allows multiple authors to collaborate on a single "work", whether that be a novel, technical manual or even source code. "Users" are allowed to "check out" chapters, make modifications and merge changes back in. Users rate each others modifications with higher ratings allowing access to more and more content.Let's call it "social version control"

While it's possible to write a single rails app that can discriminate between "works", it may be easier from a coding perspective for each work to be hosted as it's own rails app. A "master" app would create/control each works server instance, allow browsing works in search of authors, and be a reporting hub for the site owner. For now, assume the simplest of schemes where each work uses a port specific url:

Master - http://collabowork.it
My Novel - http://collabowork.it:3001
Some Manual - http://collabowork.it:3002
Another work - http://collabowork.it:3003

My question is: how many instances of rails will I be able to run on a single box before it is overwhelmed? Is there a way to determine how many instances can run on a commodity server? Is there another option that would allow scaling out additional works inexpensively (perhaps on EC2 or something similar). Because this isn't being designed as a money making venture, what's the least expensive way to deploy this (short of additional coding effort). I would like to have some sort of cost analysis before I offer alternatives but I don't know how to begin sizing something like this.

Any ideas or thoughts are appreciated.

todd
  • 21
  • 2

1 Answers1

1

I have something very similar to what you have.

We have one application located in one directory. This application is set up for mutliple different clients. The only difference between each client is the database that they use. When we set it up, I decided that having a different port for each client was not very pretty therefore we took a different approach.

I know Apache is not very popular in the Rails scene but it is still a great piece of software. We used Apache's name-based virtualhost to tackle this problem along with Passenger3. In the new version, you can define a RailsEnv per virtualhost using the same application directory. The directive is called "PassengerAppGroupName".

You get a virtualhost looking something like this :

<VirtualHost _default_:80>
        ServerName preprod.xxxx.fr
        DocumentRoot /var/xxxx/current/public/
        TimeOut 5000

        # Passenger directives
        PassengerHighPerformance on
        PassengerAppGroupName "preprod"
        RailsEnv preprod
        # Logging
        ErrorLog /var/log/apache2/preprod-error.log
        CustomLog /var/log/apache2/preprod-access.log combined

</VirtualHost>

I think this example should clear things up. This solution allows you to separate your applications using the HTTP Host used to connect to it.

To sum up, if the "works" have the same code base all you can use this IMHO clean solution.

EDIT : In terms of performance, Apache/Passenger needs 512MB of RAM. I found that anything below that will lead to bad performance but YMMV. I don't believe it requires more RAM if you add more virtual host.

Antoine Benkemoun
  • 7,314
  • 3
  • 41
  • 60