7
votes

I created a read-replica for an RDS instance, Does AWS handles the load-balancing automatically or it needs another configuration or implementation in the code ? and if so Is there a reference for that ?

Edit for more clarification When I create a read-replica how it's going to work and handle requests ? I'm asking because it gives me an endpoint, so there must be a sort of implementation for it work properly right? (alongside the master RDS)

3
There is no magic here. You need to use endpoint of read-replica in connection string when you fire a query that will only read. otherwise you use master node endpoint in connection string to update the data.Asdfg
Note that what you are probably asking about is actually called read/write splitting and not load balancing.Michael - sqlbot

3 Answers

3
votes

Unfortunately, load balancing of Aurora cluster is quite limited. First of all, it balances connection at the moment of connection being established and does not re-balance them under any circumstances, unless the connection is dropped and re-opened (but that has limitations too, see below).

Second, when Aurora does distribute the connections, it, however, does not take into account the number of connections already established to each read-replica.

Third, it does it using DNS switch process with TTL of 1 second. As result of all of the above, it is, unfortunately, very common case, when some replicas receive MUCH more connections, than others. Not to mention absence of mechanism of drying out instances for switching off etc.

Because all of the above limitations and highly unbalanced load, we've developed a fairlink JDBC driver (or rather envelop-driver) for MySQL and PostgreSQL. You can find it here: https://github.com/DiceTechnology/dice-fairlink

2
votes

Amazon provides connection load balancing for RDS Aurora database clusters, via a specific load-balanced endpoint. For any other RDS database configuration you will have to handle the connections yourself.

Edit for more clarification When I create a read-replica how it's going to work and handle requests ? I'm asking because it gives me an endpoint, so there must be a sort of implementation for it work properly right? (alongside the master RDS)

At that point you just have 2 database servers, and each server has a separate endpoint URL that you can connect to. Amazon is keeping the data between those servers in sync for you, that's all. There is no load balancing happening here. You seem to be making an assumption that there is more going on here than there actually is. If you are using an RDS database engine other than Aurora, you will have to implement the load balancing yourself.

1
votes

AWS handles RDS failover automatically, not load balancing on replication. You can configure how the load balancing between your read replicas should work using: