'Can we pass 3 url to backend(asp.net core, 1 master, 2 slave) appsettins.json have 1 connectionstring yandex cloud? postgresSql master-slave
We have datacenter in 3 zone and 3 different url. Connect to database postgres is psql "hostname=url1,url2,url3 \port=......" Yandex understand what is master now and if master with url1 broken, Yandex start using url2 or url3. url2, url3- slave. But in backend we can't pass 3 url. We connect to database with "hostname=url1 \port=......" We have only 1 url and can't using slave. Can we pass 3 url to backend(asp.net core). If database in datacenter1 work correctly - using url1, if datacenter1 broken- using url2 in datacenter2
Solution 1:[1]
There are two particular FQDN types in Yandex Cloud managed databases that can help you here: one always points to the master, second always points to the least lagging replica.
How does it work? When the master is switching in your managed Postgres cluster, a script goes to the DNS and amends the master pointing FQDN, resolving it into the correct IP. The exact process handles the consistency of the replica pointed FQDN.
You don’t have to pass three hosts. Use the master FQDN instead.
https://cloud.yandex.com/en/docs/managed-postgresql/operations/connect#special-fqdns
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Nikolay Matrosov |