5

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?

4

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.

2
  • Hi I already use HAProxy for load balancing EC2 instances via OpsWorks. If I understand correctly I need to set up a custom layer & create a HAProxy Instance in that layer to route SQL Queries, right? I also found something called MySQL Proxy for doing that how does it stack against HAProxy? Sep 13 '14 at 6:19
  • Yes, if you're using HAProxy then just setting up another instance to handle the SQL traffic should do the trick. I'm actually not familiar with MySQL Proxy, but after a quick Google search it looks like it would also do precisely what you need.
    – Bruce P
    Sep 22 '14 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.