Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon AWS: Multiple Instances, Same DB

In an Amazon AWS setup, how can two cloned instances (in different regions) refer to and share the same "base" dynamic web server files and read to / write from the same main database?

Our current AMI instance is on an EBS-backed volume right now. However, apparently trying to share an EBS volume between two instances is a bad idea. I gathered that much from this older 2009 answer, but it doesn't break down what alternatives there might be, other than Amazon S3. Or is S3 the only option? Is the OPs reasoning still valid 3 years later? What are our storage options for sharing DB data live realtime by multiple instances?

If you want shared data, you can setup a server that all your instances can access. If you are wanting a simple storage area for all your instances, you can use Amazon's S3 storage service to store data that is distributed and scalable.

Moving to the cloud, you can have the exact same setup, but you can possibly replace the fileserver with S3, or have all your instances connect to your fileserver.

like image 357
dubesor Avatar asked Dec 28 '25 16:12

dubesor


1 Answers

To confirm: You're wanting to share a) the same database and b) the same files between two instances, each in a different region (not different availability zone)?

Sharing the same database across multiple regions isn't easy. Your best option is either asynchronous, multi-master replication or a manual sharding strategy. However, to do any of these safely and effectively, it has to be carefully planned and your application has to be be written with this architecture in mind. This article will give you a good overview of the caveats associated with multi-master replication with MySQL.

Sharing files across region can also be somewhat of a challenge because you have so many options, but it is generally easier than doing the same with a SQL database. Variables include:

  • How much replication latency is acceptable?
  • Are you going to be writing to both locations?
  • What kind of I/O performance do you need locally?
  • How frequently do the files change?

GlusterFS is frequently a good compromise for most use cases. However, just yesterday AWS announced a new feature that allows inter-region copies of EBS snapshots. Depending on your needs, this may also be worth researching.

like image 117
jamieb Avatar answered Dec 30 '25 04:12

jamieb