I've set up two single-AZ read-only MySQL databases in AWS, and I want to distribute the load between them effectively. I'm considering using RDS Proxy, but I've found that it only supports one target. I also thought about using a Network Load Balancer (NLB), but I'm unsure if that's the best option. We're managing DNS through CloudFlare, which complicates things since I can't create a CNAME record with multiple targets like I could in Route53. Has anyone else faced a similar setup? What solutions did you use to load balance read-only MySQL RDS instances?
5 Answers
It's a bit unclear whether your two read-only databases are connected to different applications. If they're not, you might not need a load balancer at all. Typically, you'd connect to just one of the databases unless multiple apps require access to both.
You really don't need a dedicated load balancer. Just configure your application to randomly send requests to one of the database IPs. If one goes down, the app can switch to the other. Most connection pools should support this setup without a hitch!
But considering future scalability, each app will need reconfiguration if we add more read-only replicas. That's why I'm looking for something that can serve as a static gateway regardless of the number of instances.
It seems like AWS manages that entry point quite well. In our setup, we have a primary database and several read replicas. The application draws reads from the replicas, and there's no need for load balancing here.
Using an NLB could work. It allows you to add targets easily, so that could be a viable option for your architecture setup as you scale.
But how would I actually set the RDS endpoint as a target for the NLB?
RDS already handles high availability with multi-AZ setups. For read-only access, using read replicas should be sufficient; you don't need a load balancer on top of that.

We actually have two read replicas for our primary read/write MySQL and aim to create a single entry point for those read-only instances.