Postgresql – AWS Aurora RDS 2nd reader gets no queries

amazon-rdsaws-aurorapostgresql-10

Running a Postgres Aurora RDS with one writer and two readers.

One reader is used heavily, but the other is barely used at all according to CloudWatch.

CloudWatch

The Laravel application this is connected to points the read host to the reader cluster endpoint so that Aurora can do the balancing internally, but it does not appear to be doing that, instead favoring the 1st reader exclusively.

Is there some misconfiguration in the RDS or something else going on?

Best Answer

We have also faced the same issue and it got resolve after reduced the DNS TTL value in our Java application.

Amazon Aurora for MySQL or PostgreSQL distribute workload between reader nodes as below (From AWS Manual)

Aurora uses a DNS based round-robin load balancing mechanism for balancing connections between the reader instances. This load balancing is handled through Amazon Route 53's DNS service. This means that your application makes a DNS query for each new connection request. Each time the reader endpoint is resolved, the instance IP of one of the reader is provided for the connection. In order to get the instance IP of a different reader each time, one must keep resolving the endpoint without caching DNS. Aurora DNS cache uses a short Time to Live (TTL) of 5 seconds. To ensure both the readers are equally utilized, care must be taken not to increase the TTL more than 5 seconds for a client and network configuration. Caching DNS responses for longer than 5 seconds can result in overutilization of one reader over others as you have been experiencing.

In your application check the DNS TTL set for the application and adjust it down to 5 seconds.