Question

Should I use primary database connection string or read only connection string

Let’s say i want to scale my database for different data centers. What I need to do is to replicate the primary database and create a read-only replicate of it. And DO gives two connection strings, one is the primary and the other is read-only. Which connection string should i use for my app?

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @matthewbennett,

If you want read and write to happen to your managed database cluster you will have to use a primary database connection string.

And when a read-only node is at the different data center which is going to be used for read operations; you can use a read-only node connection string. which can offload read requests/analytics traffic from the primary database.

For more information on read-only nodes:

https://docs.digitalocean.com/products/databases/postgresql/how-to/add-read-only-nodes/

https://docs.digitalocean.com/products/databases/postgresql/#plans-and-pricing

I hope this helps!

Regards, Rajkishore