High Availability
This page explains what redundancy each plan family gives you, what you control about failover, and how a standby node differs from a read replica.
Nodes by Plan Family
The number of nodes is fixed by the plan. There is no separate switch for high availability: you get standby nodes by choosing a plan family with more than one node.
| Plan family | Nodes | Topology |
|---|---|---|
hobbyist-*, startup-*, cpu-startup-*, so-startup-* | 1 | Single node |
business-*, cpu-business-*, so-business-* | 2 | Primary and one standby |
premium-*, cpu-premium-*, so-premium-* | 3 | Primary and two standbys |
Read the node count of every plan with:
exo dbaas type show pg --plansA standby is a copy of the primary inside the same service, in the same zone, kept up to date by streaming replication. It exists to take over when the primary fails, without a restore from backup. A single-node service has no standby: if its node is lost, the service has to be rebuilt from its backups.
Because all the nodes of a service run in one zone, standbys protect against the loss of a node, not of a zone. For a copy in another zone, use a read replica.
The availability target of each plan family is in the DBaaS SLA. Moving between families is a plan change, see Change the service plan.
Replication to Standbys Is Asynchronous
The primary does not wait for a standby before it confirms a commit. The service setting synchronous-replication accepts off and quorum, but quorum is refused
on the plans tested (startup-4, business-4, premium-4) with
Synchronous replication not available for current plan.
When the primary fails, the transactions it committed and had not yet sent to a standby are lost.
Commits Are Acknowledged Before They Reach Disk
synchronous_commit is off on Managed PostgreSQL, while upstream PostgreSQL defaults to on:
SHOW synchronous_commit;With off, PostgreSQL reports a commit as successful before its WAL record is flushed to disk.
The PostgreSQL documentation on asynchronous commit
describes the consequence: if the server crashes, the transactions committed in the last moments
before the crash are lost, up to three times wal_writer_delay, which is 200ms on the service.
The database stays consistent: a lost transaction disappears as a whole.
The service-level value cannot be changed: the API answers
No data to update the service. The parameter has the user context, so avnadmin
can turn it on for a transaction, a role or a database:
BEGIN;
SET LOCAL synchronous_commit = on;
-- the writes that must not be lost
COMMIT;ALTER ROLE ROLE_NAME SET synchronous_commit = on;ALTER DATABASE DATABASE_NAME SET synchronous_commit = on;Parameters:
ROLE_NAME: the role whose sessions should wait for the flush, for example your application user.DATABASE_NAME: the database whose sessions should wait for the flush, for exampledefaultdb.
Role and database settings apply to new sessions. With on, a commit waits until its WAL is on
the primary’s disk. It still does not wait for a standby, so a failover can lose the most recent
transactions. Each commit also pays the latency of a disk flush.
Failover
Failover to a standby is automatic. There is no API operation to promote a standby, to move the primary role to another node, or to trigger a failover on demand, so a failover cannot be rehearsed. Rehearse recovery with a fork instead, see Plan for disaster recovery.
The failover detection is run by pglookout. Its one setting is how long the primary must be
unavailable before a standby is promoted:
| Setting | Minimum | Default | Meaning |
|---|---|---|---|
max_failover_replication_time_lag | 10 | 60 | Seconds of primary unavailability before failover to a standby |
echo '{"pglookout-settings":{"max_failover_replication_time_lag":90}}' | \
exo api update-dbaas-service-pg SERVICE_NAME -z ZONEParameters:
SERVICE_NAME: name of the service, for examplemy-postgresql.ZONE: zone of the service, for examplech-gva-2.
A lower value fails over sooner after a real outage, and also on a shorter network interruption.
Prepare the Application for a New Primary
The hostname of the service stays the same after a failover; the address behind it changes. A
promoted standby is another PostgreSQL server: the sessions open on the old primary are gone, and
so is their state (uncommitted transactions, temporary tables, prepared statements, SET values,
advisory locks, LISTEN registrations). The same happens when nodes are replaced during a
plan change
or maintenance.
Warning
Treat a dropped connection as a normal event. Use a client-side pool that validates connections and reconnects, keep transactions short, and make writes safe to retry.
Standbys Are Not Read Replicas
| Standby node | Read replica | |
|---|---|---|
| What it is | A node inside the service | A separate service, with its own name, plan and URI |
| Comes from | The plan (business-*, premium-*) | A read_replica integration you create |
| Zone | The zone of the service | Any zone |
| Purpose | Taking over from a failed primary | Serving read-only queries, a copy in another zone |
| Becomes a primary | Automatically, on failover | Only when you promote it |
| Billing | Included in the plan | Billed as a service of its own |
To check which kind of server you are connected to:
SELECT pg_is_in_recovery();true means a replica or a standby, false a primary.
See Use read replicas to create and promote a replica.