Bhavesh Modi
Bhavesh Modi

Reputation: 323

How to split Read traffic between multiple AWS RDS read replica and master?

I have web application which is communicating with AWS RDS (MYSQL). now we want to scale our database instance to reduce master traffic. so AWS RDS has provided "Read Replica" feature , through which we distributes traffic to reduce load on master. Now the question here is how my web application knows to redirect read traffic to read replica instance. what is best approach through which we can achieve this functionality.

Upvotes: 6

Views: 5491

Answers (2)

Munchai
Munchai

Reputation: 1

The Heimdall Proxy can split reads/writes with Strong Consistency. It is available on the AWS, Azure and GCP Marketplace. The proxy speaks monitors the RDS status via APIs to ensure proper failover and query routing. It also does not depend on DNS when tends to unevenly distribute load across read replicas. The Heimdall Proxy makes better use of your replicas.

Check out their blog: https://aws.amazon.com/blogs/apn/using-the-heimdall-proxy-to-split-reads-and-writes-for-amazon-aurora-and-amazon-rds/

Upvotes: -1

Ashaman Kingpin
Ashaman Kingpin

Reputation: 1577

There is no magic bullet; you have an endpoint for the master db and an endpoint for EACH read replica. You have to account for this in your application code, i.e. have a pool of read DB connections that point to your read replicas and a pool of write DB connections that point to your master db. In your application code, when you are doing reads, you use the read connection and writes, the master connection. You can use general design techniques to hide this from the rest of your application code somewhat (in the Persistence layer) but the other layers have to inform the Persistence layer what type of connection they want.

As an aside, why RDS + MySQL rather than with Aurora? One advantage of Aurora is that you get a single endpoint for all your read replicas and Aurora will take on the responsibility of load balancing across the available replicas. With RDS + MySQL, you have an endpoint for each replica and have to do the load balancing on your own.

Upvotes: 4

Related Questions