How does Amazon Aurora for MySQL or PostgreSQL distribute workload between reader nodes?

Last updated: 2019-04-18

How does Amazon Aurora for MySQL or PostgreSQL distribute workload between reader nodes?

Resolution

You can use the reader endpoint to connect to the reader nodes in an Aurora cluster. To understand how Amazon Aurora distributes the workload between reader endpoints, see Using the Reader Endpoint.

To verify the rotation distribution of connections, run a shell command similar to the following. To see how Aurora attempts to load balance your connections to the reader endpoint, run a command similar to the following:

while sleep 5; do dig xxx-cluster.cluster-ro-xxxxxx.us-east1.rds.amazonaws.com|grep CNAME; done

Each time you resolve the reader endpoint, you'll get an instance IP address that you can connect to, chosen based on the rotation distribution.

The DB connection to each read replica might not be distributed evenly in the following scenarios:

  • If a client caches DNS information, you might see a discrepancy in the distribution of the connections. This occurs when the client connects to the same Aurora replica using cached connection settings. DNS caching can occur anywhere from your network layer, through the operating system, to the application container.
  • If the instance is in the process of failing over, the reader endpoint might direct connections to the primary instance for the DB cluster for a short time. This occurs when an Aurora replica is promoted to the primary instance.
  • If the read replica is unavailable or fails a health check, the connections might not be distributed evenly.
  • If the application is written in Java and the TTL caching wasn't disabled or adjusted, then the connections might not be distributed evenly. For example, Java virtual machines (JVMs) might cache DNS indefinitely, if the DNS caching isn't configured otherwise. For more information, see Setting the JVM TTL for DNS Name Lookups.
  • If the connections occur at the same time, the connections are sent to the same reader endpoint.

You can use custom endpoints if you want more flexibility when managing the distribution of your workload, for example if you use different instance sizes within the cluster. For more information, see Using Custom Endpoints.


Did this article help you?

Anything we could improve?


Need more help?