Deploying on EC2 + S3
I have a little side project I'm getting ready to launch. It's a Rails app using MySQL (though database choice doesn't matter, since it's Rails). I'm considering launching the app purely on S3 + EC2. The idea is, the code will live in S3 by using the S3 filesystem component. I can develop locally and deploy via Capistrano when I push out a new release. The code is then deployed to S3 and the EC2 instance restarts.
I'm wondering if this is even viable. Has anyone else that you know of done it?
For the database, I have two options. I could either leave the database on the EC2 instance and back it up nightly and never restart the instance (since data only disappears if you restart the instance or due to a hardware failure). The advantage there is database queries are most likely much faster, since it doesn't have to hit the network for each new database query. The disadvantage is, the data may disappear at the drop of a hat, and then it's backup-restore time. The other option is keeping the database in S3, which seems totally secure but might be slow for queries. I'll, of course, be using memcached and other caching mechanisms, but database load seems like it could still play a part.
What d'you think, would you launch on EC2 + S3?
28 comments
[ 2.0 ms ] story [ 104 ms ] threadThe suggestion is to constantly write db logs from EC2 to S3 instead of nightly backup, so that in the event of a crash you're only likely to lose minutes worth of data.
Also note that you can restart instances with no loss of data. Its only in failures that you would lose data.
http://www.stormpulse.com
Python (Pylons framework) + nginx + Ubuntu + S3 + EC2
Failures, and also explicit shutdowns (ex: "shutdown -h now")
Going down the path you described will be full of pain.
Yes, it's possible to design an application to either not use a database at all, by storing _all_ your data on S3, or to implement some workarounds that deal with DB master-slave replication, store commit logs on S3, etc etc etc. Question is: is it worth it? In my opinion, no.
S3 is great if you want to store images, movies, etc and aren't very popular worldwide. EC2 is great if you need extra processing power to deal with extra traffic coming from those Digg/Slashdot stories, or doing batch processing like converting movie formats, but going 24/7 on simple EC2 or EC2+S3 (using S3 as a database and not just for storing media files) is more of a hassle than a "good enough" solution. VPS is definitely the way to go if you cannot afford to lease a couple of servers or some rackspace for the cheap 1u boxes you can buy at ebay.
I don't really need a monstrosity, just something small and reliable.
Slicehost and other similar services (VPS') are about as cheap as it can get but bear in mind that you're sharing hardware with other people so don't assume you'll be the only one using the server.
If you want real hardware, google for "managed hosting". Alternatively, if you already have a 1u server lying around or can get hold to one (or more) it may be cheaper to search for "colocation services" which should show you some companies that will provide rackspace for your servers.
Renting hardware may be cheaper but if you buy a couple of servers on ebay and go for colocation, in the event of your business going belly up you can sell the hardware and maybe get enough money to last you for a couple of months while you search for a job or make new plans for world domination.
If Amazon sorts out the other issues EC2 could be really great.
Also, even though S3 doubles as a backup medium (and you _must_ backup your database), if you want a database running on EC2 you _must_ go for S3 to store your information. That too will increase your costs.
And on top of all that, you have to spend some time tweaking and testing your configuration (and testing again). If you're short on working hands, the time you spend on this activity may not be worth it.
I think that, unless you're doing it just for fun, you should let someone else help Amazon sort out the kinks of their system.
In the end, having your entire system on EC2 will not give you an edge over your competition, but the time you save by not doing it probably will.
But ... we've found S3 to be very good for hosting big stuff, and static files. Very simple. And use the S3Fox Firefox plugin for testing and getting statics on there in the debugging phase.
http://www.serverbeach.com/catalog/cust_ref_landing_new.php?...
Seriously though, just because EC2/S3 are useful things doesn't mean you should use them for everything. Dedicated servers are unbelievably cheap and powerful now. They're also way more straight forward to work with. Scale up for a while, then scale out if you're hugely successful.
As I understand it, if your VM is powered off, you lose cached data your database will then start re-pulling from the storage engine.
You can fetch the storage module from here: http://fallenpegasus.com/code/mysql-awss3/
Relevant presentation: http://fallenpegasus.com/code/mysql-awss3/presentations/
Computerworld article: http://www.computerworld.com/action/article.do?command=viewA....
Have I done it? No. It's something I'm investigating for a startup which may have a need for elastic scalability.
My main concern: you'd need a list of consistent speed between S3 and EC2. Any current users know what this is like?
My crazy caching design shows it's benefits after all!