Sometimes the current options for paid hosting of Rails apps are just not warranted for small scale apps. Imagine a small business app where there may only be 10 or 15 users across the whole country. These are small, but very real CRUD apps that need to be accessed from a web browser by remote users, it’s just that the user count may be small. Let’s face it, not every site in the world gets a million hits a second, right? Sometimes the cost of paid hosting options is too much for these little apps, which can cost $50 to $75 a month even for the smallest hosting package. For big corporations this is no big deal, but for small mom-and-pop companies or small organizations, it’s still too much.
So, being a simple and frugal guy, I have been able to successfully host a few of these small, private login apps right in an Ubuntu Linux virtual machine that I am running inside of a Windows XP box sitting right on my local network.
Yep… A Windows XP machine running Virtual Box which has Ubuntu 10, where I used RVM to install Rails and all the Gems for the app. Then I go to a terminal window and start up the Rails development web server on a certain port, and leave it running. In most cases, the database is SQLite, but you can use anything that you can get running in your development environment. SQLite is plenty powerful enough for this small user-count scenario, even if the database is or becomes large (1GB, 5GB is no problem for SQLite).
Most of my apps do user authentication to validate the users at login. Myself or an admin for the app are the only ones who can create user accounts . The total number of daily users is usually less than 20 or so, and it is not open to public signup. It’s a low volume, privately accessed app. So, the developer environment of a simple Ubuntu / Rails machine handles it very well. The users have no idea what is happening on the back end.
I have the XP machine on a battery backup, and I have a static public IP with my business-grade internet service provider.
To handle the hits, I redirect from my main public facing router (switch) to the LAN based IP and port which the Ubuntu VM uses.
So, my users enter an address like this to hit their app (notice that a specific port is requested):
1 <a href="http://210.123.034.104:1234">http://210.123.034.104:1234</a>
(the above is a fake address, but you get the picture)
When this hits my public facing router, I redirect it to the Ubuntu Virtual Machine LAN IP and the port that I used when I started the Rails development server:
1 192.168.0.125:3003
So, with this mapping in place, I go to the virtual machine and open up a terminal, CD to the Rails app directory, and enter:
1 rails s –p 3003
to start up the server on port 3003. (You can use any free port that you have available.)
Boom! A live self-hosted Rails app.
You can run as many of these as you want. Even in the same VM you can run different ones just by change the port that is used for the Rails server, and then just create a new mapping on your switch.
Sure, since I am using SQLite, it’s single threaded hits to the database file, but hey, for what little traffic this thing gets each hour, it handles it very easily, and the users never feel any speed issues.
Pros: Free, full control, hands-on, dang… it just works! Trust me, I’ve been doing it for months!!!
More Pros: Because it’s a VM , about 20GB is enough size, and you can backup or clone the entire machine as a single file.
Cons: Keeping the host XP machine and the VM alive all the time, keeping my internet connection alive, keeping the Ubuntu updates applied (if needed), backing up the data file(s).
What about Heroku ? Just saying…
Outch !
Why cannot simple install a ubuntu on a machine under a desk ?
Why not try Heroku (free to start).
Soo if you want keep this dirty way. You can install :
– Put your VM in bridge network (IP on network)
– Apache+passenger -> “pro” Rails hosting
Did you know that you can host a full Rails application with even a small database on Heroku for $0 ?
If you choose to use MongoDB and MongoLab you can even have 200Mb of free database storage.
That should be enough for your “10 or 15 users across the whole country”.
Why not using the free plan of Heroku ?
Interesting post, Matt. Thanks for sharing!
You could use pagekite.net as well, and do all that without ever mucking with your router.
The major problem with the free plan of Heroku is that the dyno falls asleep after a certain time, and asks 10-15 seconds to be woken up … It’s not annoying to test its website (pre-production), but for a site, even if it’s tiny, I think it’s annoying.
Heroku is great. But if you need more than the tiny 5Mb database that they provide (assuming an SQL like database), you aren’t going to use Heroku for free or cheaply anymore.
@Julien: Get a Pingdom account. They are free if you are only using it for one site. Ping your site every 5 minutes. Problem solved.
Thank you! The exact info I was looking for.