1
votes

We're planning to move our Tomcat/MySQL app onto the Amazon cloud employing 2 EC2 instances (inst_1 & inst_2) running in different availability zones whereby inst_1 will contain the master RDS db and inst_2 the slave RDS db.

If we employ elastic load balancing to balance traffic between the two instances, will traffic directed to inst_2 that includes insert/update/delete db transactions first update the master RDS db in inst_1 followed by a synchronous update of the slave in inst_2; thereby ensuring that the two RDS instances are always synchronized?

Amazon's published info (whitepapers) suggests such, but doesn't explicitly state it. If not, how does one ensure that the two RDS instances remain synchronized?

Additional note: We're planning to employ Amazon's Elastic Beanstalk. Thanks!

2
Are these just 2 random instances, a multi AZ setup or an normal instance & a replica ?Frederick Cheung
Frederick - Good point. It appears that we may not yet fully understand the distinction between a multi-AZ and a "normal instance & a replica". We intend to run RDS in multi-AZ mode and were expecting the resulting "slave" to exist within inst_2, but obviously your question suggests that these are distinct configurations . . .Greg Henson

2 Answers

2
votes

You have to take a few things into consideration

  • AWS RDS instances are simple managed EC2 instances which run a MySQL server.
  • If you add a slave ( I think Amazon calls them read-replica) this is a read-only slave
  • Amazon doesn't manage the distribution of writing queries to the master server automatically.
  • Replication will ensure that your read slave always is up-to-date automatically ( with minimal delay which is increasing with write-load on the master )
  • This behavior is MySQL-specific

This means that you have to delegate manipulating queries to the master exclusively.

This can either be done by your application or by a MySQL proxy running on a extra machine.

The proxy then is the only interface your application servers will talk to. It is able to manage balancing between your RDS instances and the direction of any manipulation query to the master instance.

1
votes

When RDS is used in multi-az mode you have no access to the secondary instance. There is only ever one instance that is visible to you, so most if your question doesn't apply. In case of failover the DNS address you are given will start resolving to a different ip. Amazon doesn't disclose how the two instances are kept in sync.

If instead of using a multi-az instance you use a single-az instance + a replica then it is up to you to direct queries appropriately - any attempt to alter data on the replica will fail. Since this is just standard MySQL replication, the replica can lag behind the master (in particular with current versions of MySQL the replica only runs a single thread)