How do I do routing for MySQL Read Replica?

1.6k Views Asked by At

I have created 2 read replicas of my master mysql database on rds.

now all 3 have different connection endpoints.

1) does it mean that i have to manage random selection of these endpoints for my queries?

2) further to confirm, does it mean that I have to ensure that all my sql write queries needs to be routed to master endpoint

3) Is there any ways in which routing can be handled programmatically? ie db load balancing

1

There are 1 best solutions below

2
On BEST ANSWER

1) Yes you have to manage it using some tool. read this - http://www.tecmint.com/install-haproxy-load-balancer-in-linux/2/

2) Yes , you have make sure that write's are redirected to master only. That can be done by defining seperate connection parameters to read and write with different hostnames.

3) Try HA PROXY its better way than handling it in code (ref link in point 1)