ZEKTOR.IO Docs

High Availability

Run a PostgreSQL database as 3 copies on separate servers, with automatic failover and the same connection string.

Overview

A normal Zektor.io database runs on one server. If that server fails, the database is down until it is replaced. With high availability the database runs as 3 copies, a primary and two standbys, each on its own server. If the server holding the primary fails, a standby takes over automatically.

You switch high availability on when you create the database.

High availability is a PostgreSQL feature, and it is rolled out gradually. The High availability switch only appears on the new-database page for regions where it is available to you, and only for the plans it can be had on there right now.

What a copy is

Each copy is a full PostgreSQL instance with your whole database in it, on a different server from the others. The primary takes reads and writes. The standbys follow it continuously and are ready to take over.

Your connection string is the same whichever copy is the primary, and it does not change after a failover.

No confirmed write is lost

A commit waits until any one of the two standbys has it. That standby is the one that takes over, so a failover loses nothing that was confirmed to your application. With one standby down, writes keep going with the other.

Waiting for a standby makes each commit a little slower than on a single database, typically by a millisecond or two within a region.

What a failover looks like

  1. The server with the primary fails
  2. A standby is promoted, within about a minute
  3. Open connections drop once
  4. Your application reconnects to the same host and finds the new primary

Queries in flight when the primary fails will fail. Everything after the reconnect works as before.

On every failover we email you, and the database's page in the dashboard shows Last failover and how many copies are ready, as of the last check (about once a minute).

Make your application ready

A failover is a connection drop, so the application must reconnect rather than give up. See also connection resilience.

  • Set a connect timeout, for example connect_timeout=10 in the connection string, so a connection attempt that hits a failing server does not hang
  • Make your connection pool retry on connection errors, with a short back-off
  • Retry transactions that failed because the connection dropped, and only those that are safe to repeat
postgresql://user:password@host:5432/db?sslmode=require&connect_timeout=10

Pricing

Each copy is billed as a database. A database with high availability costs three times its plan, and storage above what the plan includes is billed for each copy too. The price on a plan is for one copy.

Billing is prorated by the hour like any other database. Amounts on your invoice and in Usage already include the number of copies.

Limits

For now:

  • Chosen when the database is created. High availability can't be switched on or off afterwards. To change it, create a new database and migrate into it
  • PostgreSQL only, on plans with 1 to 16 GB of memory
  • The first one in a region takes longer. Creating it can take about 15 minutes instead of a few
  • No branches of a high-availability database yet
  • Limited availability. Not every region, plan, or account can choose it yet

Next Steps

  • Connecting — Connection strings and resilience
  • Backups — Backups and point-in-time recovery
  • Pricing — Understand costs for each tier

On this page