Skip to content

Read replicas

A replica is a second compute on the same data as its primary, read only. It adds capacity for reads without copying anything.

Terminal window
peat replica orders orders-read

or

apiVersion: peat.zabaca.com/v1alpha1
kind: Database
metadata:
name: orders-read
spec:
replicaOf: orders
  • It is reached like any database: by its own name, with a Secret orders-read-login holding the primary’s login.
  • It lags the primary slightly, as any streaming replica does. A write is refused with Postgres’s own error (“cannot execute … in a read-only transaction”).
  • It sleeps and wakes on its own. Waking a replica does not wake its primary. A woken replica takes its first connection only once it has caught up with every write the primary had acknowledged before the wake.
  • It runs its primary’s Postgres version. To move the primary to a newer version, delete its replicas, move it, and make them again.
  • A replica of a replica, or a branch of one, is refused. Make it from the primary.
  • Deleting the primary waits until its replicas are deleted.