Use case

Design PostgreSQL high availability after an outage that took the primary down

Typical situation: a retail platform lost its PostgreSQL primary during a busy trading hour, a person promoted a replica by hand, and the last seconds of orders were missing. The design answer has three parts. PostgreSQL ships no software to detect a dead primary, so a tool such as Patroni must do it, and its documented default leader lease is 30 seconds. Streaming replication is asynchronous by default, so losing the primary can lose recent commits unless synchronous replication is configured. And the application must reconnect cleanly. OSStend designs all three, runs the cluster in your cloud account and rehearses failover on a schedule. Background reading is in PostgreSQL high availability.

45 minutes with an engineer: we review your workload and sketch the design.

  • Design
  • PostgreSQL
  • Your cloud account
Topology
Primary plus 2 replicas across 3 zones
Detection
Patroni with etcd, ttl 30 s by default
Durability
Quorum synchronous commit, ANY 1 of 2
Where it runs
Your cloud account
Deliverable
Signed design plus a failover drill

Typical situation

Trigger. An availability-zone outage took the primary and a manual promotion lost the final seconds of writes.

Versions. PostgreSQL 16 or 17 with Patroni and etcd.

  • Order and payment commits must survive one node loss
  • Checkout traffic peaks on promotion days
  • Three zones available

A typical situation, not a named customer.

A PostgreSQL high availability design needs failure detection, a durability rule and a client reconnect plan. With Patroni defaults (ttl 30, loop_wait 10, retry_timeout 10), automatic failover starts after about 30 seconds. A quorum such as synchronous_standby_names = ANY 1 of 2 keeps commits on a second node.

Customers

  • Microsoft logo
  • Henry Schein logo
  • Enbridge logo
  • Gojek logo

Partners

  • Broadcom logo
  • Redis logo
  • VMware Tanzu logo
  • OSSeva logo
160+Enterprise customers
10+Years running these systems
24/7Engineers on call
3Places it runs: our cloud, yours, your data center
Engines we run, on the platforms you already use
  • PostgreSQL
  • MySQL
  • MongoDB
  • Redis
  • Valkey
  • OpenSearch
  • Kafka
  • RabbitMQ
  • AWS
  • Google Cloud
  • Azure
  • Kubernetes
  • OpenShift
  • Prometheus
  • Grafana
  • Datadog
  • Dynatrace
  • Splunk
Compare

What OSStend runs and what you keep

OSStend writes the design, builds it and runs the failover machinery. You own the application behavior during a failover, which is half of the result.

AreaOSStendYou
Cluster designAn engineer writes the design: size, replica layout, versions, extensions and settings. You sign it off before anything is built.Approve the design and name the change windows.
Build and moveBuilds the target and owns the move, with both sides live until you switch.Point the application at the new endpoint on the agreed day.
Backups and recoveryBase backups, continuous WAL archiving and restore tests, with point-in-time recovery.Say how far back you must be able to recover.
FailoverDetects a dead primary and promotes a replica; checks the old primary before it rejoins.Use connection retry in the application.
Upgrades and patchingMinor releases and major upgrades on your change calendar.Set the freeze dates.
Monitoring and on callReplication lag, oldest transaction ID age, bloat, WAL archiving and disk, with engineers on call 24/7.Receive the alerts you want forwarded.
Application and schemaAdvice on queries and indexes found during the review.Your schema, your queries, your releases.
ContractOne contract, one on-call team, price quoted per design.Retry connections and make writes idempotent.

Where it can run

A three-zone cluster fits most cloud accounts, and the same design runs in a data center with three racks or rooms. The licences involved are permissive.

OptionWhen it fitsLicence and source
Your cloud accountThree zones in one region and your network rules.PostgreSQL License, a permissive licence similar to BSD or MIT (PostgreSQL project, checked 23 Nov 2026). It places no limit on where a managed service runs. Patroni is MIT (GitHub, checked 23 Nov 2026).
Our cloudYou want the cluster run without hosting it.PostgreSQL License, a permissive licence similar to BSD or MIT (PostgreSQL project, checked 23 Nov 2026). It places no limit on where a managed service runs.
Your data centerThree failure domains exist on site.PostgreSQL License, a permissive licence similar to BSD or MIT (PostgreSQL project, checked 23 Nov 2026). It places no limit on where a managed service runs.
How it works

How we run it

The design fixes the failure rule first, then the durability rule, then the drill that proves both. Patroni requires loop_wait + 2 x retry_timeout to be at most ttl.

  1. Review the outage (1 to 3 days)

    Timeline, lost commits, connection behavior and what the application did during the promotion are written up.

  2. Choose durability (2 to 4 days)

    Per table class, we decide what may be lost: nothing for orders, seconds for sessions. That sets synchronous_commit and the standby quorum.

  3. Set timing (1 to 2 days)

    Leader lease, loop and retry values are set against the zone network. Defaults are ttl 30, loop_wait 10, retry_timeout 10.

  4. Build and fence (1 to 2 weeks)

    Patroni, etcd on three nodes, a pooler and the old-primary rewind or rebuild path are installed.

  5. Drill (1 to 3 days)

    We kill the primary, a zone and etcd members on a test copy and time each recovery against your target.

  6. Run (ongoing)

    Engineers on call 24/7, with a drill repeated each quarter.

Time ranges are typical for databases of this size and are fixed in the design you sign off. The method, the order and the checks do not change with the range.

patroni dynamic configuration (example values)
ttl: 30
loop_wait: 10
retry_timeout: 10        # loop_wait + 2 x retry_timeout <= ttl
maximum_lag_on_failover: 1048576   # bytes a standby may lag and still be elected
synchronous_mode: true
synchronous_node_count: 1

Cost basis

High availability costs more than one node in three places: the extra replicas, the cross-zone traffic and the commit latency of waiting for a standby. OSStend's fee is quoted per design.

The cloud lines are public. Using the RDS list as a yardstick for the same compute, a 4 vCPU, 32 GiB node costs $348.94 a month on demand before storage, so two extra replicas add about two such nodes plus their disks.

ChoiceWhat it buysWhat it costs
Asynchronous replicasFast commits; recent commits can be lost on failoverLowest latency, no commit wait
synchronous_commit on with ANY 1 of 2Each commit is flushed on one standbyOne cross-zone round trip per commit
remote_applyReads on the standby see the commitAdds replay time to commit latency
Third zone etcd memberKeeps quorum when one zone is lostOne small node
Extra replicaRead capacity and a second failover targetA full node and its disk

Node figure: db.r7g.xlarge $0.478 x 730 = $348.94, AWS Price List file for Amazon RDS in us-east-1 (version 20261120224619, published 20 Nov 2026), US East, on demand, USD, 730-hour month, checked 23 Nov 2026. Excludes data transfer, backup storage beyond the free allocation, Reserved Instance discounts and taxes. Documentation: synchronous replication, Patroni settings, checked 23 Nov 2026.

What we watch on call

The failure patterns that cost money in this design are quiet ones: a standby that is silently behind, and clients that never reconnect.

Standby too far behind to elect.
maximum_lag_on_failover blocks promotion. Signal: replay lag per standby.
Synchronous stall.
If the only synchronous standby dies, commits wait. Signal: commits blocked and sync_state in pg_stat_replication.
etcd quorum loss.
Without a leader store Patroni demotes the primary. Signal: etcd member health in all three zones.
Old primary rejoining dirty.
It must be rewound or rebuilt. Signal: timeline divergence after a failover.
Clients stuck on a dead address.
Signal: pooler errors and connection counts after the drill.
Enterprise only

When OSStend is not the right fit

Design work pays off when an outage already cost real money or when commits must not be lost. A single-node dev database does not need it.

Contact us if

  • Lost orders or payments are unacceptable.
  • You run more than one zone or room.
  • You want a rehearsed failover, not a hoped-for one.
Talk to an engineer

Not a fit if

  • The database is internal and can be restored overnight.
  • You only need a read replica for reporting.
  • Your application cannot reconnect and cannot be changed.
FAQ

Questions buyers ask

Talk to an engineer →

How long does automatic failover take?

Patroni documents ttl as the time before automatic failover starts, with a default of 30 seconds, then promotion and client reconnect follow. We measure the total in the drill.

Can we lose zero commits?

With synchronous replication to at least one standby, a single node loss does not lose acknowledged commits. The cost is commit latency, which the design measures.

Does this need Kubernetes?

No. On Kubernetes an operator does the detecting; on VMs Patroni does. See PostgreSQL high availability.

Talk to an engineer

Review your last outage with an engineer

Bring the incident timeline. An engineer will mark where the design failed and what to change.

  • A design sketch for your workload, not a plan menu
  • A zero-downtime cutover path for what you run today
  • A price for that design, after the review
See pricing →

Your request goes to the OSStend team. No newsletter sign-up.

Get a quoteTalk to an engineer
2Engines Optional
3Where should it run?
4What do you need?

Your request goes to the OSStend team. No newsletter sign-up.