Configure high availability
A database with one instance has no failover: if its node fails, the database is down until the instance comes back. Standby instances keep a copy of the primary, so one of them can take over when the primary fails. To configure high availability, add a standby, then choose a replication mode that sets how much data a failover can lose.
Prerequisites
Section titled “Prerequisites”- Edit access to the project: the Admin or Member project role.
- A dedicated database.
- Available quota for each new instance.
Add a standby
Section titled “Add a standby”- Open the database.
- Go to Settings > Resources.
- In Instances, increase the number of instances.
- Select Scale to
<number>.
The Instances list shows each instance as Primary or Standby, with its status. A new standby copies the primary before it serves traffic.
Choose a replication mode
Section titled “Choose a replication mode”The replication mode controls when Postgres treats a write as saved.
| Mode | Behavior | Needs a standby |
|---|---|---|
| Async | A failover can lose the last moments of writes. | No |
| Preferred | Each commit waits for a standby while one is healthy. | Yes |
| Required | No acknowledged write is lost, but writes stop if no standby is reachable. | Yes |
- Open the database.
- Go to Settings > High availability.
- Select a mode. Orchard saves the mode immediately.
orchard db replication set <dbId> --mode preferredTo read the current mode, run the following command:
orchard db replication get <dbId>Remove a standby
Section titled “Remove a standby”- Open the database.
- Go to Settings > Resources.
- In Instances, decrease the number of instances.
- Select Scale to
<number>. - In the confirmation dialog, select Scale to
<number>.
The primary keeps running.
Standbys also serve read-only traffic. To send reads to them, refer to Read replicas.
Related resources
Section titled “Related resources”- Monitor a database - Watch the Replication lag panel.
orchard db replicationreference - Review the replication commands.