Sharing a Database Across Multiple EC2 Instances

amazon ec2

I recently set up a micro instance on Amazon EC2, and I was wondering what the process was for sharing a database across instances. Would the easiest solution be to have one instance be dedicated to running the database, and then have all other instances communicate directly to it?

Also, I've read on several sites that EC2 instances should not be considered to be that "reliable". Keeping that in mind, would I then have to have multiple failover instances for my db?

Thanks

Best Answer

This is one of those "it depends" questions; you can certainly have multiple EC2 instances accessing a single database, with access controoled via AWS security groups. You could colocate the DBserver with one of the clients that accesses it if the DB server's resource requirements are modest enough.

If the uptime requirments for the database are stringent enough, you should look into having a separate instance for failover. It all depends on how much downtime you can afford. Definitely use EBS volumes to store the database files, since those will persist even if the EC2 instance running the DB server goes down.

A general principle for working with EC2, or any other infrastructure on demand service, is that you should always design your instances with the assumption that they will go down unexpectedly at some point. Again, how far you want to go with that depends on your uptime requirements.