RDS Aurora URLs
When we create an Aurora cluster with a writer instance and reader instance(s), there are quite a few URLs to connect our application to. We explore the when and why of each.
Cluster URL
In the format of <name_of_the_cluster>.cluster-<some_random_ID>.<aws-region-id>.rds.amazonaws.com
The primary URL sends all queries to the primary instance. Writes happen on primary instances, and hence, cluster URL is often the default choice if we need instant read of data written. The data is most consistent for read-write with cluster URL.
Cluster Read Only URL
In the format of <name_of_the_cluster>-ro.cluster-<some_random_ID>.<aws-region-id>.rds.amazonaws.com
Any requests to read only URL are load balanced to one or more reader instances in the cluster. Practically, a delay of 80-100ms is normal for the data to sync from the writer instance.
The typical use case would be analytics, reports generation, any scheduled workloads with only read access.
Instance level URLs
In the format of <name_of_the_database_instance>.<some_random_ID>.<aws-region-id>.rds.amazonaws.com
If the cluster has only 2 instances with one writer and one reader, the cluster URL and read-only URL suffice for all scenarios and instance URLs might not be obvious.
However, with multiple read-only instances each with varying memory/CPU, load balancing URL would distribute queries equally among all instances.
i.e. An analytics query of about 200 seconds and a report generation query of takes about 2 seconds are treated in the same manner.
Thus, one type of workload slows down other workloads hence impacting the latency. In such scenarios, individual URLs help control routing and fine grain connections.
Connecting to database instance URL would mean the single point of failure (instance going down or any operation such as modifying name). Thus, individual URLs are appropriate for scenarios with acceptable rare downtime.