Who is this EC2, and is he related to that robot from Star Wars?
Um … no. EC2 stands for “Elastic Compute Cloud”; it’s a “web service designed to make web-scale computing easier for developers.” Try telling your mom that.
In mom-speak: EC2 is a way to cheaply and quickly set up virtual computers. That means you could set up a virtual machine running Fedora Core with RMagick, LAME, and ffmpeg, and then add 15 more instances at the click of a mouse.
OK, my mom still won’t care, but if you’re building a YouTube MeToo, then you probably will. Why?
Reasons for using EC2 instead of dedicated or VPS hosting
- It’s elastic: add capacity almost instantly (even programmatically, if you want)
- Root access to a real box: “Each instance predictably provides the equivalent of a system with a 1.7Ghz x86 processor, 1.75GB of RAM, 160GB of local disk, and 250Mb/s of network bandwidth”
- Pay as you go: $0.10 per instance-hour, so you hold on to more of your money for longer (Web 2.0 bootstrappers, take note)
Think: easy staging environments, clustered database servers, on-demand compute scalability, backups to S3 (EC2 to S3 transfer is free)...
There’s plenty of debate about whether this is the smartest, most reliable, or even most cost-effective option for most developers1 . But at the end of the day I moved my applications to EC2 because I like trying new deployment options, and because it’s not hard, and because I wanted to learn how to do it.
At about $72/month per instance (plus bandwidth), it’s cheaper than many VPS options (though not the cheapest), and I like getting charged only for what I use. I’m always playing around with new ideas/applications; with EC2, I can launch an instance, throw an application on it, and take it down two hours later.
Managing your EC2 instances
So, you’ve decided to use EC2, and now you need a production environment. What next?
You need a way to start, stop, monitor and save machine instances. Amazon’s Getting Started Guide is, well, a good place to start. It’ll walk you through setting up the EC2 comand-line tools, launching an instance, terminating it, bundling it, and cleaning up.
But here’s a secret: if you want to skip right to the good stuff, check out RightScale (previously called AWS-Console). It’s a web-based interface to EC2, and it’s free (for now)! After you sign up at RightScale, you’ll be able to launch, monitor, terminate, bundle, and even backup Amazon machine instances, all from the safety of your web browser! Yay! And if you don’t have your own EC2 Beta account, RightScale will even give you ten instance-hours to play with for free.
It’s that easy?
Actually yes. Here are the steps, simplified:
- Using the method of your choice (RightScale, EC2 UI, or command line tools), launch an Amazon Machine instance (it’s easy). You now have a fully functioning machine, with root access. I recommend using the stock Fedora Core 4 base image provided by Amazon.
- Set your box up up for Rails2.
- Point your domain at your EC2 instance. If you don’t have a nameserver, you can use EveryDNS to manage this for free.
Things That Might Go Wrong
OK, so your ‘server’ is really just a virtual machine running somewhere in Amazon’s cloud, so if it crashes, dies, barfs, or becomes otherwise incapacitated, Amazon doesn’t guarantee that anything you put on it will be recovered when you restart it. What does that mean? You probably shouldn’t use EC2 to host content, like images, files, mp3s etc. Put that stuff somewhere else, like, say, S3. Same with your database; make sure you’re backing it up frequently to S3 or some other safe place3 .
Now, if you’ve customized your machine instance with all kinds of goodness (gems, Rmagick, mongrel, etc), you’ll want to bundle that sucker up in case it dies and you need to re-launch it, or in case you want to add another 16 of them. Again, here’s where RightScale comes in handy, letting you bundle a running instance and save it to your S3 account with a few clicks.
Also, your EC2 instance doesn’t have a guaranteed, permanent IP address. If it goes down, it might come back up with a new address… so you’ll want to figure out a way to make sure your domains still resolve if that happens4 .
Real World, Please
Is anyone crazy enough to be using this stuff in production? Well..
- University of California at Santa Barbara – some thorough examinations of the feasibility of using EC2 for real-world apps.
- RightScale itself!
- Powerset (see the COO’s announcement)
- GigaVox Media
- Smugmug (mostly S3 I think)
Should you use EC2 to host your next world-changing web application? The answer is clear: I don’t know. But it’s easy enough and cheap enough to play with that you should at least spend some time checking it out. You could spend a full work-day testing on EC2 and it’d cost you $0.80.
I think small/solo Rails developers in particular should give it a hard look, because with EC2 you can offer your clients a data center in addition to your development skills. And that’s not a bad tool to have in your toolbox.
1 Is EC2 cheap or expensive? Depends on how you look at it: here’s a good cost comparison versus some other common hosting options, and here’s a lively discussion on the costs.
2 Setting up a Rails-ish stack on EC2 is the same as setting it up anywhere else. Here are some helpful links: Link , Link , Capistrano tasks setting up your server , Deprec makes this easy (if you’re on Ubuntu). You get the idea.
3 Here’s a nice tutorial on S3 backups from my friends over at Slingshot Hosting; these instructions would work just as well on your EC2 box (aside: if you’re looking for a more managed environment than EC2, I highly recommend Slingshot).