News for hackers. Stuff that matters.

Ask HN: Explain AWS

Ok, so I might be completely missing something here, but bear with me. I want to use AWS to build my service. But I am a bit perplexed when it comes to storage. If I have MySQL running where do the database files get stored? Does each EC2 instance come with a certain amount of storage? Would be glad if someone explained this for me :)
( 31 comments | 50 points | on HN )
Re:Ask HN: Explain AWS by delano on Tuesday May 05, 2009 @05:13PM (#594752)
Every EC2 instance has about 150GB of transient disk space. It works like a regular disk but once you shutdown the instance (or in the rare event the instance fails) the disk is gone forever. To solve this problem, Amazon provides EBS volumes ("elastic block storage"). These are like raw disks that you can create on the fly. You create one, attach it to your instances, give it a filesystem, and then mount it.

You can run MySQL off of the transient disk ("/mnt") but you should consider running it off of an EBS volume. One reason is because you won't lose the disk if something happens to the instance. Another is that you can use the snapshots feature to create instant backups of your database. Later on you can create new EBS volumes from a snapshot (which is really cool for building a stage environment with production data).

This may sound a bit complicated when you're just starting out. It was for me anyway so after working with AWS for a couple years I started working on a development and deployment tool for EC2. The configuration is entirely via a Ruby DSL.

You define the properties of your environments and roles with the machines DSL (including EBS volumes) and you script your repeatable processes (like deployments) with the routines DSL:

http://github.com/solutious/rudy/blob/0.7/Rudyfile

If Python is more your style, there's boto: http://code.google.com/p/boto/

Re:Ask HN: Explain AWS by iamelgringo on Tuesday May 05, 2009 @06:10PM (#594822)
I've found it easier to think of an EC2 image's 150GB of 'disk' as RAM, and Elastic Block as an actual hard drive. EC2's disk is there when it's powered on, but when you turn it off, all data disappears. Elastic block is really EC2's hard drive.

Two issues that burned me a couple of months ago with EC2 and Elastic Block:

I built my server and got it running just right. I then wanted to back it up, so I bundled it (save your instance to S3) but forgot to register it(list your S3 bundle as a privately available AMI). When I terminated my instance I wasn't able to restart it, because it wasn't available in my list of registered AMI's. I had to rebuild my server from scratch.

The second problem that I had was in rebuilding my database after my instance terminated. Postgres keeps the log files (transactions the database has completed) in the install folder and the data file(what the database has stored) in the storage folder. When I terminated my instance, I lost all the log files that were stored on the EC2 'disk'. I had the data file on elastic block, but the log files were gone. The standard recovery process for postgres needs log files.

It took me a day to figure out how to rebuild the database from just the data files. I now have both the database and the log files on my elastic block image. Hopefully that will help the next time I kill my server. :) I also now have automated backups of everything.

Re:Ask HN: Explain AWS by delano on Tuesday May 05, 2009 @06:26PM (#594833)
Ya, getting burned by EC2 is a rite of passage. I learned my lesson with Amazon's API tools. Dealing with IDs is cumbersome and dangerous when it comes to production instances. Automation is a necessity.

How are you running your automated backups? Have you automated deployment too?

Re:Ask HN: Explain AWS by wiemersl on Wednesday May 06, 2009 @08:06AM (#595592)
Have used ec2 and s3 for a while now in a production context. While there may be cheaper services out there, we've appreciated the ability to scale up and down rapidly, build test environments, etc. It really depends on where you are at in the cycle of a project. If you are running MySQL, and want high availability, you likely want replication, which means multiple instances no matter what provider you choose. With replication, the fact that your disk is transient isn't as big of a deal. The way I look at AWS is that it nudges you in the right direction as far as building reliable, scalable systems.

As far as EBS, another thing to think about is instance types. Since EBS is essentially network attached storage (I believe), network IO greatly affects performance. Small instances don't have particularly great io. Thus, I prefer to run off the transient disk right now over EBS. If we went to larger instance types, which have better network io, that might swing the pendulum.

Re:Ask HN: Explain AWS by mindhacker on Tuesday May 05, 2009 @10:55PM (#595095)
I've used EC2 for running web servers as well as database server with the db servers being replicated to rackspace for backup.

I have always wondered about how EBS as disk will affect database as it is essentially a network drive. Any info on that would be great.

Re:Ask HN: Explain AWS by psranga on Wednesday May 06, 2009 @01:01AM (#595239)
Yes, does anybody have data on latency and throughput of EBS "disks"?
Re:Ask HN: Explain AWS by delano on Wednesday May 06, 2009 @01:02PM (#596152)
I ran a few preliminary EC2 disk benchmarks in September: http://solutious.com/blog/2008/09/23/ec2-disk-performance-li...

The Solaris performance was really poor compared to Linux. I emailed Sun and initially they were really receptive but never explained what was happening. I'm hoping to re-run the tests again soon to see if the latest OpenSolaris (2008-11) has improved.

Re:Ask HN: Explain AWS by gsmaverick on Tuesday May 05, 2009 @06:07PM (#594817)
Thanks for your reply. I now understand how it all works.
Re:Ask HN: Explain AWS by reconbot on Tuesday May 05, 2009 @08:12PM (#594941)
That's a dangerous statement ;-)
Re:Ask HN: Explain AWS by keefe on Tuesday May 05, 2009 @05:48PM (#594799)
Each EC2 instance is a virtual, private server which looks just like any other linux box. However, files on disk are part of shared drives and are not guaranteed to persist. You have three choices : attach and pay for an elastic block store that IS persistent, make periodic backups to S3 or forgo the use of the disk altogether and use SimpleDB instead of mySQL. I'd recommend using an elastic block store.
Re:Ask HN: Explain AWS by latortuga on Tuesday May 05, 2009 @06:27PM (#594835)
I'll back this up with the addendum that SimpleDB has useful applications where using it might be a better choice than MySQL (e.g. a service that gets lots of reads but real-time updates isn't necessarily mission critical)
Re:Ask HN: Explain AWS by keefe on Wednesday May 06, 2009 @02:42PM (#596448)
I think it's also interesting to note that once you do a cluster, you have a distributed system and instantaneous writes are no longer a cheap operation... Plus how many operations do you need to access full data in your database? For simple one off access, you could propagate the changes into ram on each of your cluster machines (memcached) and only relatively "unimportant" search operations would see stale data.
Re:Ask HN: Explain AWS by lrm242 on Tuesday May 05, 2009 @05:15PM (#594754)
Each EC2 instance comes with a certain amount of transient storage. It is transient because it does not persist beyond instance termination. Amazon also has persistent storage for your EC2 instances called Elastic Block Store. EBS volumes will persist beyond instance termination and can be attached to any running instance (but only one at once) within the same availability zone.

If you're running MySQL on EC2, it's pretty straightforward. You get an EBS volume for your database and back that volume up to Amazon's S3 service. S3 will then provide multi-site redundancy for your data in the event of AWS availability zone failure.

Re:Ask HN: Explain AWS by wave on Tuesday May 05, 2009 @06:09PM (#594819)
Others mostly answered your question, but if you like to run MySQL on Elastic Block Store (EBS), you should read the following article:

http://developer.amazonwebservices.com/connect/entry.jspa?ex...

If you take the approach described in the above article, you should think about creating a symbolic link to your EBS volume instead of changing MySQL configuration file.

Re:Ask HN: Explain AWS by mollylynn on Tuesday May 05, 2009 @05:25PM (#594771)
If you haven't done so already, check out RightScale (www.rightscale.com). They offer a dashboard that helps users access AWS.
Re:Ask HN: Explain AWS by just_the_tip on Tuesday May 05, 2009 @07:45PM (#594915)
Or you can just use Amazon's console.

https://console.aws.amazon.com/

Re:Ask HN: Explain AWS by mindhacker on Tuesday May 05, 2009 @10:57PM (#595098)
Create a free RightScale account and check out their shell scripts. One can get good ideas of automation from them.
Re:Ask HN: Explain AWS by nolanbrown23 on Tuesday May 05, 2009 @06:04PM (#594815)
I used Engine Yard Solo for working with AWS. It's great service and really easy to get started with Rails app on EC2. You've got to wrap your head around how EC2 works but I really love the ability to start up a brand new server on the fly and do whatever I need to do, and then shut it down.
Re:Ask HN: Explain AWS by jawngee on Tuesday May 05, 2009 @06:10PM (#594821)
a. Unless you like throwing money out the window, there is no need to host your stuff on AWS. It's the most expensive of the cloud offerings. Go with Linode or Slicehost.

b. You'll have to use EBS if you want persistent disk storage with an AWS instance. Otherwise when you reboot, goodbye to everything on your harddisk.

But, seriously, reconsider your aims of putting up a 24/7 web hosted up on EC2. You're wasting money.

Re:Ask HN: Explain AWS by delano on Tuesday May 05, 2009 @07:48PM (#594918)
You can do things with EC2 you can't do anywhere else.

I've helped companies build deployment processes with EC2 that allows them to launch a staging environment with a single command that includes a complete copy of production data. They run their tests, then cut a release and shutdown the staging environment with another single command. That's not possible without EC2 and EBS.

Re:Ask HN: Explain AWS by jawngee on Wednesday May 06, 2009 @03:27AM (#595373)
Also, you are wrong. You can do that on slicehost with their API as well.

In fact, with the slicehost api, you can take a snapshot of currently running system, and clone a new slice from that snapshot.

Re:Ask HN: Explain AWS by delano on Wednesday May 06, 2009 @06:29AM (#595520)
Can you create, attach, and take snapshots of multiple disks with Slicehost?
Re:Ask HN: Explain AWS by jawngee on Wednesday May 06, 2009 @03:21AM (#595367)
But he's talking about hosting, not staging. And what you are describing is a good use of EC2. Hosting 24/7 is not.
Re:Ask HN: Explain AWS by delano on Wednesday May 06, 2009 @06:37AM (#595526)
Staging is one aspect of hosting. I will go even further and say that because a staging environment needs to mimic the production environment as close as possible it should be hosted by the same vendor too.

You're right that if you compare numbers directly, some aspects of EC2 are more expensive than other vendors. My point is that AWS offers greater value by allowing you to do things you can't do anywhere else.

Allocating static IP addresses on the fly for example.

Re:Ask HN: Explain AWS by jrockway on Tuesday May 05, 2009 @09:34PM (#595013)
Depends on how much disk space you need. With Amazon, the space is virtually limitless, and transfers to and from S3 are free. With Slicehost and Linode, you get really tiny disks, and you have to pay for bandwidth to S3 if you need more.

It's also hard to dynamically scale with Slicehost or Linode. You can't have a script bring an instance up for an hour and then shut it down when the load drops off. (Actually, you probably can, but that's not what it's designed for.)

Obviously EC2 is not for everyone, but it is good if you need its features.

Re:Ask HN: Explain AWS by keefe on Tuesday May 05, 2009 @07:38PM (#594906)
After a cursory googling, it looks like AWS is still the only one where you can programatically modify the number of nodes in your cluster. If your goal is to launch a public facing site and automatically scale up to some limit as you get users, then AWS is a good choice. With AWS you are buying automated scalability and amazon's reliability (not that rackspace doesn't know what they're doing)
Re:Ask HN: Explain AWS by jawngee on Wednesday May 06, 2009 @03:28AM (#595374)
Re:Ask HN: Explain AWS by keefe on Wednesday May 06, 2009 @12:56PM (#596127)
Interesting, I see those entries... I had been looking at this :

http://www.slicehost.com/articles/2008/3/26/announcing-the-s...

". Please note that the current iteration allows access to DNS only."

I guess they had another iteration since then, thanks for the info!

Re:Ask HN: Explain AWS by iamelgringo on Tuesday May 05, 2009 @06:15PM (#594827)
It is one of the cheapest ways to get a Windows 2003 server slice, if that's your cup of tea, however.
Re:Ask HN: Explain AWS by enjo on Tuesday May 05, 2009 @10:36PM (#595082)
Amazon provides a host of support services (Cloudfront CDN anyone??) that are trivial to manage from an existing EBS volume. The extra services that Amazon offers really make the process of going from zero to scale much simpler (albeit not 'easy') than any other host or collection of tools that I've used.

That makes it worth the slightly higher costs for me.

Re:Ask HN: Explain AWS by mattsmall on Thursday May 07, 2009 @12:11PM (#598151)
RightScale's paid edition has prebuilt MySQL Master-Slave configurations with or without EBS. EBS is great if your transaction volume is average, but on high IO disks it can get prohibitively expensive. The RS Manager for MySQL has failover, recovery tools as well. All you need to do is plug in your DB dump.

RightScale's Developer Edition is always free - AND - RightScale Website Edition is FREE for Ycombinator startups while you're actively engaged in the program.