Skip to content

Multi-AZ

Multi-AZ runs a dedicated Postgres database on two servers: a primary and a synchronous standby in another city. It is chosen when the database is created; it is temporarily unavailable while only one city has database server capacity.

  • A synchronous standby. Every commit waits until the standby confirms it has the write-ahead log. A write the database acknowledged is not lost if the primary fails.
  • Automatic failover. If the primary stops renewing its lease, LeafCloud starts a failover by itself. Nobody runs a command.
  • The same hostname. Clients keep using the database’s hostname. Its DNS record moves to the new primary, with a 30-second TTL.
  • A rebuilt old primary. After the failover, the old primary rejoins as the new standby. It discards its old data and copies the new primary.
  1. About 45 seconds after the primary’s last lease renewal, the control plane sees that the primary is gone and that the standby is alive and was in sync.
  2. The old primary is fenced, so it cannot accept writes. The standby is promoted, which takes about a second.
  3. The database’s hostname is pointed at the new primary. The record has a 30-second TTL, and the DNS sync applies changes every 30 seconds, so clients may keep reaching the old address for up to a minute.

In practice a failover takes about 2–3 minutes from the moment the primary stops until writes work again. Our test on real servers measured 161 seconds. Writes pause while it happens. Connections open at that moment close, and a transaction that had not committed must be retried.

  • Keep using the same hostname, port, user and password. Nothing changes in the connection settings.
  • Retry a failed connection. A connection pool recovers on its next attempt.
  • Retry the transaction that was open when the primary stopped. If the database did not acknowledge the commit, the transaction did not complete.
  • Do not connect to the standby. It takes no client writes; the primary is the endpoint.

Until the rebuilt standby has caught up and reports that it is synchronous again, the database runs without a synchronous standby. Writes are faster in that period. LeafCloud turns synchronous mode back on when the standby is ready.

  • There is no SLA and no uptime guarantee, during the beta or after it.
  • The control plane is a single server today. Automatic failover needs it. If it is down, no failover happens: the database loses availability rather than risking two primaries accepting writes.
  • At most one automatic failover runs per database per hour. A second failover inside that hour needs an operator.
  • Multi-AZ needs a dedicated plan and two dedicated servers in different cities.
  • Synchronous commits add one cross-city round trip to every write. Read-heavy workloads are less affected than write-heavy ones.

Multi-AZ does not change backups: they run from the current primary, and a restore works across a failover. See Backups and restore.