What are EC2 Best Practices?

There's scant documentation on this topic.

For example, the EBS initialization described in this page is an important first step for running a database on EC2:

http://docs.amazonwebservices.com/AWSEC2/latest/DeveloperGuide/index.html?instance-storage.html

I found this page buried in the Amazon Developer Guide. I think they call the Sysad guide "Developer Guide".

I have other questions as well, for example: How should you backup databases? Setup a standby database on another EC2 instance? Or use the EBS-S3 backup feature?


Solution 1:

A few basic ones off the top of my head:

  • Use EBS rather than instance storage for all data that needs to be persistent.
  • Keep an offsite backup of all critical data. Amazon quotes EBS as being 10 times more reliable than physical drives, but you want to guard against the Amazon services becoming unavailable.
  • Use security groups carefully to control access to your instances. When you need to add a port to a security group, restrict it to other addresses on the AWS network if possible.
  • Security groups can also be used to identify your EC2 instances (who can remember a bunch of names like "i-a27999c" ?) For example, if you have a set of web servers and a set of application servers, use different security groups for each set even if the access rules are the same.
  • Use elastic IP addresses if you want to have a fixed IP address for external access that can move between different instances. If you have a single, long running instance, I wouldn't bother with elastic IPs.
  • If you plan to run your instances for an extended time, consider Reserved Instances; you pay an upfront fee but then get a much lower hourly rate.

On the backup question, either of your options could be good - the standby database would give you faster recovery but you'd be paying for the extra EC2 instance and its EBS volume. Using S3 for backups has the advantage that you only pay for the storage you use; if you have another EBS volume for backups, you pay for the total size of the volume even if you're not using all the storage space.