Load Balancing RDS (in AWS)

I am new to AWS in general so this might be a noob question. I have set up an RDS instance with a readreplica & connected my VMs to the the Master DB for now via AWS Opsworks. Ideally I want the reads balanced between master and slave and the writes to only go to the master.

Ofcourse I do this in code but that will be messy especially if I want to add more RDS Slaves or if I delete one or more of my instances.

So is there something I have missed? Is there some configuration that AWS provides that I have not come across yet to seamlessly do this?


Solution 1:

AWS does not (currently) support load balancing of RDS instances in this manner, so you would need to implement this sort of thing yourself. There are a number of different approaches you could take to set up something like this yourself:

  1. As you stated you could do this in your own code, which would be a little messy.

  2. You could try using round-robin DNS to implement a basic form of load balancing. If you're not familiar with round-robin DNS, it's basically a way of using DNS to return different IP addresses for each query. See Amazon's documentation on weighted routing for more information on setting this up in Route53.

  3. You could incorporate a simple proxy/load balancer like HAProxy or balance either on one of your existing app servers or on a separate small instance and let it manage load balancing between the RDS instances.

There are likely other options (including other load balancing apps) but one of these is likely going to be the simplest solution for your needs.