skip to Main Content

I’m currently trying to connect to Aurora DB.
I know that I should use the endpoint as the hostname but the problem is Aurora has 4 endpoints.

Cluster Endpoints: Reader and Writer
Instance Endpoints: Reader and Writer

Which should I use?

2

Answers


  1. The cluster’s writer endpoint connects to the primary instance and can be used for both write and read operations. For the reader endpoint, if the cluster has no replicas, then it also points to the primary instance and thus, is equivalent to the writer endpoint. If there are replicas, then it will load balance read operations across the replicas. Therefore, if you’re doing a high volume of reads, it’s best to use the reader endpoint to reduce load on the primary instance and keep it free for writes.

    Instance endpoints connect to individual instances (either the primary or a replica). You should use it if you want full control over how reads are distributed across the replicas. For writes, since both the writer endpoint and the primary instance endpoint connect to the primary instance, there is no functional difference between the two.

    To be clear, an instance does not have both a read and write endpoint. There is only one endpoint, and it acts as a read endpoint if the instance itself is a reader. In other words, the instance endpoint of a replica is a read endpoint, and the endpoint of the primary instance is a write endpoint. The exception to this is Multi-Master Aurora, where all instances are writers.

    More info here: https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Overview.Endpoints.html

    Login or Signup to reply.
  2. Good answer from Tyler. The writer endpoint is the general-purpose one that always gets some use. All else being equal, stick with that one. The others are for more specialized purposes.

    For Aurora, the instance endpoints are the least likely to be used. Because depending on whether a failover happened, instance XYZ might be read/write or read-only, so why would you hardcode it into a connection string when the R/W vs. R/O aspect might change. The reasons for using an instance endpoint are more for debugging (what is happening on instance XYZ to make it run slower than the others) or advanced performance stuff (run all the reporting queries on instance ABC because that uses a bigger instance class than all the other ones).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search