I've recently set up a read replica to take some of the read load off of my Amazon multi-AZ RDS instance. The Amazon documentation clearly states that it is "up to your application to determine how read traffic is distributed across your read replicas".
Has anyone figured out a manageable way to scale read replicas? It doesn't seem like a very extensible solution to have different parts of my application hard-coded to read from specific replicas. Is there a way to set this up that is analogous to putting EC2 instances behind a load balancer?
An AWS engineer provided some insight into the question here.
Here is a snippet of his response:
in general you can load-balance traffic at the following 3 logical places:
- Application layer - create multiple connection pools and send all reads to the read-replicas.
- Web framework/middleware - some web frameworks have in-built support for multiple databases [1].
- External proxy - You can use an external proxy like MySQLproxy [2].
[1] - https://docs.djangoproject.com/en/dev/topics/db/multi-db/