A Case for EC2


When iLike’s Facebook application took off here is how they handled it:

“In our first 20 hours of opening doors we had 50,000 users sign up, and it is only accelerating. (10,000 users joined in the first 12 hrs. 10,000 more users in the next 3 hrs. 30,000 more users in the next 5 hrs!!)”

“We started the system not knowing what to expect, with only 2 servers, but ready with backup. Facebook’s rabid userbase chewed up our 2 servers almost instantly. We doubled our capacity to catch up. And then we doubled it again. And again. And again. Oh crap – we ran out of servers!! Although iLike.com has a very healthy level of Web traffic, and even though about half of all the servers in our datacenter were sitting unused, idle, as backup capacity, we are now completely maxed out.”

“We just emailed everybody we know across over a dozen Bay Area startups, corporations, and venture firms in a desperate plea to find spare servers so we can triple our capacity for the continued onslaught. Tomorrow we are picking up over 100 servers from different companies to have them installed just to handle the weekend’s traffic. (For those who responded to our late night pleas, thank you!)”

Seems like a good case for EC2.


Rails Cookbook


I want to give a quick plug to O’Reilly’s Rails Cookbook by Rob Orsini. A lot of the time when trying to figure out a coding problem, I rely on google searches. Some reference books are so good that if I have a problem, I learn to go to the book first before doing a google search. The best example for me is the Pragmatic Version Control book by Mike Mason. When I have a SVN problem, I go to that book.

The Rails Cookbook has not become the first source for rails programming as has Pragmatic Version Control, but I’ve turned to it a number of times when google searches have not yielded the results I needed.

The strong point of the Rails Cookbook is its breadth. It provides a lot of examples. Two that I found very helpful were 3.17 on acts_as_tree and 6.3 on modeling relationships restfully with join models. Both these examples crystallized the solution faster for me than any found blog posts or discussion items. I’m sure there will be more examples like that.

Rails Cookbook does not go into as much depth of explanation as the recipes in Rails Recipes by Chad Fowler. But that is okay. There are more of them and most of the time I’m not reading the explanations as much as looking for code samples. In that way, Rails Cookbook is great.

The AWS folks posted my screencast 7 Steps to Easy Rails Deployment to their articles and tutorials section.

Off to Europe


I’m traveling to Europe today for business. I’ll have spotty email access while in transit.

I’ve turned my capistrano/ec2 deployment recipes into a plugin. Installation is:

ruby script/plugin install svn://rubyforge.org/var/svn/elasticrails

I’ve also created a wiki at http://www.elasticrails.com (link) to facilitate commenting, revising, and editing the recipes.

There are several deployment gems out there, such as deprec, RailsMachine, SlingShot’s, and capazon. I prefer a plugin, because the library files are easier to find. I thought a wiki would be useful too to use a best-of-breed approach to aggregate recipes.

Check it out and add your own recipes to the wiki. I’ll take the best ones and add them to the plugin.

The default specs for an EC2 instance include 165GB of local storage. That storage is split between 2 partitions. The default partition (/) is 9.85GB, with the rest in /mnt, which Amazon calls their “ephemeral storage”.

One problem that I ran into is the default location for installing applications, including mysql, is the default partition. So my mysql database was initially stored in what was left of the 9.85GB on the root drive. As the database grew, it quickly started to consume all of the storage on this partition.

I recommend you change your mysql data directory to the /mnt drive.

Here is how I did it.

Step 1. Backup your database!

Step 2. Shutdown mysql

service mysqld stop

Step 3. Create a new data directory on /mnt and change

mkdir /mnt/mysql_db

Step 4. Change ownership of that directory to the same owner of your rails app

chown steveodom.www /mnt/mysql_db

Step 5. Modify the mysql config file

whereis my.cn

=> /etc/my.cn

vi /etc/my.cn

Which will look like this:


datadir=/mnt/mysql_db/ #was /var/lib/mysql/
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).



Noticed I changed the very first line to point to /mnt/mysql_db.

Step 6. Move your databases to /mnt/mysql_db

mv mysql/your_database_name /mnt/mysql_db/

Step 7. Restart mysql

service mysqld start

I had never used a favicon for a site before.  I just added one to my upcoming quizical.net site. I ran into one small problem that I thought I would add here.

I created a 16 x 16 icon, named it favicon.ico and added it to my public folder (not public/images). Yet, the icon was not showing up in my browser.

Some poking around revealed that I must add the following between my document head:

<link rel="shortcut icon" href="/favicon.ico" />

Once I added that, it works fine. Easy.