PostgreSQL synchronous replication and quorum commit

Synchronous replication decides how many standbys must confirm a commit before the client sees success, which sets your data loss exposure, write latency and failover behavior. This page explains how to choose between asynchronous, priority and quorum modes and how to plan for a standby failure.

On this page

Why PostgreSQL synchronous replication changes what a failover can lose

A team that needs its primary to survive a server loss without losing acknowledged transactions must make commits wait for standby servers. With synchronous replication, a commit on the primary does not return success until the named standbys have confirmed the write, so an acknowledged transaction exists on at least one other server. PostgreSQL supports three replication modes that matter here: asynchronous replication, where the primary does not wait; synchronous replication, where a commit waits for standbys; and hot standby servers, which accept read-only queries while they replicate. Asynchronous replication is the default, so a team that wants the durability guarantee must configure it explicitly.

The documentation is equally clear about what PostgreSQL does not do. It does not include software that detects a failed primary and tells a standby to take over. Synchronous replication protects the data on the standby, but promotion, fencing of the old primary and redirecting clients all come from external tools or from your own runbook. A synchronous setup without a tested failover process protects data that nobody knows how to bring back online. Confirm which tool will perform detection and promotion before you decide how many standbys must confirm each commit.

The choice is a trade-off between durability and write latency. Every synchronous commit pays the round trip to the standby that confirms it, so a slow or distant standby raises the response time of every write on the primary. Waiting for more standbys raises the guarantee but also the chance that a single standby outage stalls writes. Before you pick a mode, measure the network round trip between the primary and each candidate standby in your environment, and decide with the business which transactions can tolerate losing their last few seconds and which cannot. The configuration options that express those decisions are covered in the sections that follow.

Asynchronous, priority and quorum modes compared

This table compares asynchronous replication, priority-based synchronous replication and quorum-based synchronous replication on data loss at failover, write latency, tolerance of a standby failure and configuration effort. Read each column as the cost you accept in exchange for stronger durability, and confirm exact syntax for your PostgreSQL version in the official documentation before you configure anything.

AttributeAsynchronousPriority-based synchronousQuorum-based synchronous
How commit waitsCommit returns after local WAL flush only; standbys receive WAL laterCommit waits for the standby(s) that are currently first in the listed priority orderCommit waits for any N of the listed standbys to confirm, whichever respond first
Data loss on primary failureTransactions committed on the primary but not yet streamed can be lost on promotionCommitted transactions are on at least one synchronous standby, so loss is limited to settings that relax the waitCommitted transactions are on N standbys, so loss is limited to settings that relax the wait
Write latencyLowest; no network round trip is added to commitAdds a round trip to the chosen standby on every commit that waitsAdds a round trip to the Nth fastest eligible standby, which can be lower than priority-based latency when one listed standby is slow
Tolerance of one standby failureNot applicable; primary keeps accepting writesCommits stall if the current sync standby fails unless another listed standby takes over the roleCommits continue while enough other listed standbys remain to meet N
Configuration complexityLow; no synchronous settings requiredModerate; one ordered list defines which standby is synchronousModerate to high; the quorum count and the candidate list must be kept in step with cluster membership
Main operational riskSilent divergence between committed and replicated data after failoverStalled writes when the priority list does not match healthy standbysQuorum set may be sized too small to survive a failure or too large to keep writes flowing
How synchronous_commit fitsSetting synchronous_commit to off or local is typical; standbys are not waited onSetting remote_write, on or remote_apply controls how far the standby must go before commit returnsSame levels apply; the quorum list decides which standbys count toward the wait

How a quorum commit waits for standbys

The diagram starts when a client sends COMMIT to the primary, which writes the WAL record to its own disk and sends it to each candidate standby. The client gets success only after enough standbys in the quorum confirm the WAL is flushed, or applied, depending on synchronous_commit. The box marks the database hosts you control, separate from the client's side of the trust boundary. Check the branch where too few standbys respond: the commit does not return success, so the application must handle waits and timeouts.

Primary waits for a quorum of standby confirmations before the client sees success.

Sizing the quorum and placing standbys across failure domains

The number of standbys you list and the number of confirmations you require decide whether a single failure stops writes. With synchronous_standby_names set to ANY 1 (standby_a, standby_b), the primary needs one acknowledgment from either standby, so losing one standby leaves a confirmation source. With FIRST 1 (standby_a) or a single listed standby requiring one confirmation, the commit has exactly one place to get its acknowledgment. If that standby fails, commits wait until it returns or until you change the setting. A quorum of one out of one listed standby is therefore a configuration that stalls writes on a single fault. Before go-live, count the standbys that must be healthy for commits to proceed, and confirm that the number of listed standbys exceeds the required confirmations by at least one.

Placement determines what a single fault removes. Two standbys on the same host, rack, power feed or storage array can both disappear in one event, which leaves the quorum count intact on paper and empty in practice. Map each standby to its physical and power domain, then check that the confirmations you require can be satisfied by standbys in different domains. The PostgreSQL high availability documentation covers the replication modes these choices depend on, and your own infrastructure inventory must confirm the actual domain boundaries. Test this by stopping each domain in turn in a non-production environment and observing whether commits continue.

Latency is the cost of that placement. Every synchronous commit waits for the acknowledgment from a standby, so the network round trip between the primary and each synchronous standby is added to every write that uses that level of durability. Measure round-trip time and jitter on the actual links, at peak load, before choosing a standby location. A cross-site synchronous standby adds a wide-area round trip to every commit, which may be acceptable for low write rates and unacceptable for high-throughput workloads. Ask your network team to confirm link latency and packet loss figures in writing, and rerun your write-latency tests on those links before committing to a topology.

How to configure synchronous standbys in order

This sequence takes a running primary and its standbys from plain streaming replication to a configured synchronous set, with a check at each step so you can confirm which standbys hold commits before the primary acknowledges them. It assumes you already chose between priority and quorum form.

  1. Confirm standbys are streaming

    Before changing any setting, check that every intended standby is connected and receiving WAL. On the primary, query pg_stat_replication and confirm each standby appears with a state of streaming and a small replay lag. On each standby, confirm it is in recovery and that its WAL receiver is running. Do this first because a standby that is not connected cannot be made synchronous, and a standby that is lagging will slow every commit that waits for it. The step is done when every intended standby shows as streaming on the primary.

  2. Set a unique application_name on each standby

    The primary identifies standbys by the application_name each one sends when it connects, so set it in primary_conninfo on each standby, for example through postgresql.conf, ALTER SYSTEM, or your automation. Give every standby a distinct name that your team can map to a host, such as a site or role suffix. Duplicate or empty names make the synchronous list ambiguous. Restart or reload as your version requires, then reconnect. The check is that pg_stat_replication on the primary shows each standby under its new application_name with no duplicates.

  3. Write synchronous_standby_names on the primary

    On the primary, set synchronous_standby_names to the form you chose earlier. Priority form lists names in order, such as FIRST 1 (name_a, name_b), so the first connected name in the list is the synchronous standby and the rest are candidates. Quorum form uses ANY n (name_a, name_b, name_c), so a commit waits for any n of the listed standbys. Names must match application_name exactly, and an empty value makes replication asynchronous. Confirm the syntax against the version you run in the high availability documentation before you apply it. The check is a syntax-clean configuration with no parse error in the server log.

  4. Reload the configuration without restarting

    Synchronous standby settings take effect on a configuration reload, so run pg_reload_conf() or send a reload signal rather than restarting the primary. Changing this setting does not require a restart, and a reload keeps client connections open. Check that the new value is active by running SHOW synchronous_standby_names in a session. Confirm the server log shows no rejected parameters. The step is complete when the running value matches the file on disk.

  5. Verify sync_state in pg_stat_replication

    Query pg_stat_replication on the primary and read the sync_state column for each standby. A standby in the synchronous set should report sync for priority form, or quorum for quorum form, while others report potential or async. Standbys that remain async are not holding commits, so an unexpected async value means the name did not match or the standby is not connected. Record which standbys are in the synchronous set, because that list defines the durability you are claiming. The check is that the reported set matches your design exactly.

  6. Choose the synchronous_commit level

    Set synchronous_commit to the level your data needs. On, the default when synchronous standbys are configured, makes a commit wait until the standby has flushed the WAL to disk. Remote_apply also waits for the standby to replay the change, so readers on the standby see it, at a higher latency cost. Local and off trade durability for speed, and a local setting does not wait for standbys at all. You can set the level per session or per transaction for specific workloads. Document the chosen level for each workload class, since it determines what a failover can lose. The check is that SHOW synchronous_commit returns the level you documented for each role or session.

  7. Test the commit wait behavior

    Run a test in a non-production copy or a maintenance window. Insert a row on the primary and time the commit, then stop one synchronous standby and repeat. With the standby down, a priority configuration should wait on the next candidate, while a quorum configuration should continue only if enough standbys still acknowledge. If too few standbys remain, commits block until a standby returns, so confirm your team knows this behavior before go-live. Record the observed latency and the blocking outcome. The step is done when the test results match the design and the runbook includes the recovery action for a blocked commit.

Choosing a synchronous_commit level by workload

Ledger and payment writes usually cannot tolerate losing a transaction that the application has already reported as committed. For these workloads, the usual starting point is on, or remote_apply where reads on a standby must see the write immediately, combined with a synchronous standby set that stays available when one node fails. With on, the commit waits until the synchronous standby has flushed the WAL record to disk, so a promoted standby holds every transaction the client was told succeeded.

  • Guarantee on failover: with on or remote_apply, a committed transaction is present on the synchronous standby that is promoted, provided that standby was in sync when the primary failed.
  • Availability trade-off: if no synchronous standby can acknowledge, commits wait. Confirm whether the business accepts stalled writes or needs a documented fallback path.
  • Latency cost: each commit pays a network round trip to the standby plus that standby's flush time, so measure across the real network link before choosing remote_apply.
  • Lower levels excluded: off and local do not meet a zero-loss target for these writes.

Confirm with the business owner whether the recovery point objective for these writes is zero, and whether a stalled commit path is an acceptable failure mode.

What happens when a synchronous standby fails

Synchronous replication trades write availability for durability, so the outcome of a standby failure depends on how the standby set is written and how many confirmations the primary needs. The four cases below cover the outcomes operators most often misjudge, and each one changes what clients see and what the operator must check first.

Priority standby fails and the next takes over

In a priority list such as FIRST 1 (node_a, node_b), the primary waits on the highest-priority standby that is connected and streaming. When that standby drops, PostgreSQL moves the synchronous role to the next listed standby, and clients typically see a short pause in commits rather than an error. Check that the remaining standby is actually streaming, that its name matches application_name exactly, and that pg_stat_replication shows it in sync state. PostgreSQL does not promote a standby on its own; failover tooling decides that.

HA docs

Quorum setup still confirms commits

With quorum commit, such as ANY 1 (node_a, node_b), the primary needs confirmation from any one of the listed standbys, so losing one standby leaves commits unaffected. Clients see normal latency, but durability is now held by fewer copies than before. Confirm that enough standbys remain connected to meet the quorum count, and alert when a standby disappears, because the system keeps running with less redundancy until it returns. Failover decisions still belong to external tools that check which standby is most current.

Quorum lost and commits block

When fewer standbys remain connected than the quorum requires, a commit on the primary waits for confirmation that cannot arrive, so client sessions hang rather than fail with a clear error. The operator must either restore a standby quickly or change synchronous_standby_names or synchronous_commit to a level that no longer waits, accepting the durability trade-off in writing. Check the wait_event values on blocked backends and the connection state of each standby before deciding. Promotion of a new primary remains a tooling decision, not a PostgreSQL one.

Slow standby raises latency silently

A standby that is connected but slow, perhaps on a saturated disk or a congested network link, causes no error, yet every commit that waits on it takes longer. Clients experience rising response times that look like an application problem. Watch replication write, flush and replay lag in pg_stat_replication alongside commit latency, and set alerts on lag thresholds your application can tolerate. Decide in advance whether a persistently slow standby should be removed from the synchronous set by an operator or by failover tooling.

Measuring write latency before go-live

Every synchronous commit waits for the standby, so commit latency rises by at least the network round trip to the standby plus the time that standby needs to flush WAL to disk. The penalty is small for a single slow query and much more visible under concurrency, because many small transactions queue behind the same flush and acknowledgment cycle. Your own numbers depend on your network path, your storage and your transaction shape, so the team should measure them on its own hardware before choosing a synchronous_commit level or a synchronous_standby_names policy for production.

Build a staging copy of the cluster with the same PostgreSQL major version, storage class, network path and standby count as production. Replay a representative workload, ideally captured from production or modeled from it, with the same concurrency, transaction size and read/write mix. Run it twice: once with replication asynchronous and once with the synchronous policy you are considering, keeping every other setting identical. Use a load tool that records per-transaction commit timings, and report p95 and p99 commit times rather than averages, since tail latency is what application timeouts and retry storms respond to. Repeat each run enough times to see whether results are stable.

Record three more signals alongside commit latency. Track replication lag on the primary during the run, including how far the standby falls behind under peak write bursts. Watch the standby's disk flush behavior with operating system I/O metrics and PostgreSQL's own statistics, since slow fsync on the standby is the most common source of synchronous delay. Finally, document the baseline in a short table kept with the runbook, so later changes to synchronous_commit, standby count or hardware can be compared against your figures. Confirm the exact view names and statistics available for your PostgreSQL version against the high availability documentation before you write the monitoring queries.

Security and operational risks of synchronous standbys

Synchronous replication moves a database risk into the network and the operations team. A standby that holds a commit hostage, or a credential that lets the wrong host replicate, can affect both data protection and write availability. The cards below cover the controls to set before a synchronous standby goes live, and the checks to repeat after every change.

Scope replication roles and host access

Create a dedicated role with the REPLICATION attribute for each standby, rather than reusing an administrative account. Add pg_hba.conf entries that match the replication pseudo-database and name only the standby addresses, so no other host can open a replication connection. Review these entries whenever a standby is replaced. Broader authentication design is covered elsewhere in the PostgreSQL pillar.

HA docs

Encrypt replication traffic

WAL carries the full content of every committed change, so the replication channel needs the same protection as client connections. Enable TLS on the primary and require it for replication connections from pg_hba.conf, and confirm that standbys verify the server certificate rather than accepting any certificate. Test that a connection without TLS is rejected before go-live.

Alert on sync state and lag

A synchronous standby that drops to asynchronous or disconnects changes your durability guarantee without raising a client error. Watch pg_stat_replication for sync_state values and the replay and write lag columns, and page on a change of state, not only on high lag. Treat an unexpected drop of a quorum member as an incident, because the remaining standbys may no longer satisfy the commit rule.

HA docs

Write a runbook for blocked commits

If every named synchronous standby is unavailable, sessions that commit with synchronous_commit set to on or higher wait and may appear hung. Write a runbook that tells the on-call engineer how to confirm the standby outage, how to decide whether to relax synchronous_standby_names or accept asynchronous operation, who approves that change, and how to restore the setting afterward. Rehearse it in a test environment.

Control changes to synchronous_standby_names

This setting decides how many standbys must confirm a commit, so changing it changes write availability as well as durability. Store it in version-controlled configuration, require a second reviewer, and record which standbys are named and why. Confirm the expected behavior after each change with a test commit before closing the change ticket. Confirm the exact syntax and reload behavior for your PostgreSQL version in the documentation.

What buyers ask before choosing synchronous replication

How much more effort does synchronous replication add compared with asynchronous replication?

Synchronous replication adds effort mainly in design, testing and operations rather than in the basic setup. Enabling it means naming standbys in synchronous_standby_names, choosing a synchronous_commit level, and deciding what happens when a standby is missing. Every commit waits for confirmation from the standby, so the team must measure write latency on realistic network paths before go-live. Asynchronous replication avoids that wait but accepts that recent commits can be lost after a primary failure. Operationally, a synchronous setup needs monitoring for standbys that fall out of the sync set, and runbooks for what the application sees while writes are blocked. Ask your team or partner to list each of these items in the written scope so the added work is visible before the build starts.

What drives the cost of a synchronous replication implementation?

The main cost drivers are the number of standbys, the number of sites, the testing scope and the failover tool in use. More standbys mean more servers to provision, more replication roles and pg_hba.conf entries, and more combinations to test under failure. Multiple sites add network links whose latency and reliability must be measured, and they usually raise the cost of fencing and runbooks. Testing scope matters most: a team that only confirms replication works will spend far less than one that kills standbys, partitions the network and measures commit stalls. The failover tool, such as Patroni, repmgr or pg_auto_failover, changes how quorum and promotion are configured. The cost is mostly labor, paid to whoever builds the system, and the quote should list each standby, site and test case separately. Ask for the one-time build cost and any retainer for ongoing support as separate lines.

Can our own team configure synchronous replication without outside help?

A team with PostgreSQL operations experience can configure synchronous replication itself, provided it has time to test the failure cases. The configuration itself is short: a standby list in synchronous_standby_names, a synchronous_commit value, and matching standby settings. The harder part is deciding how many standbys must confirm a commit, how the cluster behaves when one is down, and how the application handles blocked writes. Mistakes here usually appear only during failures, so the team should plan for a dedicated test environment and clear acceptance criteria. Outside help is most useful when the team lacks recent experience with a failover tool, has several sites, or needs evidence for an assessment. Ask for a written list of what the team will build, what it will test, and which decisions it will record, so the team can judge the gap honestly.

How long does testing synchronous replication take, and what makes it longer?

Testing duration depends on the number of failure scenarios, the environment available for testing and how much evidence the team needs to record. No fixed duration is supplied for this work, so ask for a schedule in the written scope rather than relying on a general estimate. Scenarios that usually take the most time include a standby stopping during peak writes, a network partition between sites, a primary crash during a commit, and a failover that promotes a standby which was lagging. Each scenario needs a measured result for commit latency, client reconnection and data loss, and each result may require a rerun after a configuration change. Environments that are not production-like add time because results must be checked against real hardware and network paths. Ask for the list of scenarios and the acceptance criteria for each one before agreeing on a timeline.

What does the work need from our team in hardware, network access, maintenance windows and test data?

The work needs several resources from your team, and each should be confirmed before scoping. Hardware must include primary and standby servers with storage and memory sized for your workload, plus, where a witness or consensus store is used, separate hosts for it. Network access must allow replication traffic, the failover tool's cluster communication and administrative access for the builders, with firewall rules approved in advance. Maintenance windows are needed for configuration changes that restart the primary and for the planned switchover tests. Test data should resemble production in volume and write pattern, because commit latency depends on it. Ask your team to confirm each item in writing, and to name the people who approve network changes and maintenance windows, since delays in those approvals often drive the schedule more than the technical work.

Does synchronous replication alone prevent split-brain?

No, synchronous replication alone does not prevent split-brain. It reduces data loss by making commits wait for standbys, but it does not decide which server is the primary or stop an old primary from accepting writes after a network partition. PostgreSQL does not include software to detect a primary failure and notify the standby, so automatic failover depends on an external tool, and that tool must fence the old primary. Protection usually comes from a consensus store with leader locks, a watchdog device, or fencing scripts, depending on the tool chosen. Teams should test a partition explicitly and confirm that the isolated primary stops accepting writes. Ask any partner to show the fencing design and the test results that prove it, because a synchronous configuration that looks correct in normal operation can still allow two primaries during a network failure.

Limits to confirm in your environment

Synchronous replication depends on version-specific syntax, the failover tool's behavior, your network, and your client libraries. The cards below list the checks to complete before a quorum commit design is approved, because each one can change whether writes block, how promotion behaves, or whether applications recover cleanly.

Confirm the version and support window

Check which PostgreSQL major version you will run and when its support ends. The versioning policy lists end of support dates for each release, and PostgreSQL 14 is the earliest supported version listed, with support ending November 12, 2026. A synchronous design that outlasts a version's support window needs an upgrade plan built in from the start. Confirm the minor release you will deploy and your patch cadence, since minor releases arrive at least once every three months.

Versioning policy

Confirm synchronous_standby_names syntax

Read the parameter reference for your exact release before writing synchronous_standby_names. Confirm the priority form, the quorum form using ANY n, the standby application_name values each replica must set, and how the setting is reloaded. Test the string on a non-production cluster and verify the active synchronous standbys in the replication status view, because a typo can leave a commit waiting on a standby that never matches.

HA and replication docs

Confirm failover tool handling

PostgreSQL does not detect a failed primary or promote a standby on its own, so the external tool you choose decides how synchronous standbys are treated during promotion. Ask the vendor or project how it selects a candidate, whether it respects the synchronous standby list, and what happens when no synchronous standby is healthy. Write down the answer and test it, because the default behavior may favor availability over zero data loss.

Confirm latency and bandwidth between sites

Every synchronous commit waits for a standby to acknowledge the WAL, so the round trip between primary and standby sets a floor on write latency. Measure round-trip time and sustained throughput between the servers and sites in your design under peak write load, not idle conditions. If a standby sits across a WAN link, a quorum that depends on it can make every commit slower and may stall writes during a link degradation.

Confirm client reconnection after failover

After promotion, applications must reach the new primary and retry transactions that were in flight when the old primary failed. Confirm whether your driver or connection pooler supports multiple hosts, target session attributes and retry logic, and whether your application treats an uncertain commit as failed or as possibly committed. PgBouncer and your routing layer each affect how quickly clients move to the new leader, so test this path with the actual client stack.

PgBouncer project

Confirm replication and monitoring access

Synchronous replication needs a dedicated replication role, pg_hba.conf entries that allow standby connections, and network rules between the nodes. The failover tool and monitoring system also need read access to replication status views. Confirm with your security and network teams that these connections, roles and ports are permitted by policy, that the replication credentials can be rotated, and that alerts fire when a synchronous standby drops out of the set.

Authentication methods

How DeployOpen scopes and delivers synchronous replication

DeployOpen plans, builds, tests and documents PostgreSQL synchronous replication and quorum commit inside your own infrastructure. The work starts from your durability and latency requirements, then produces a configuration your database and operations teams can review, run and hand over without relying on us.

How we scope

  • Written scope names the replication mode per standby, the quorum count and the standby failure behavior you accept.
  • We record the commit durability requirement and which transactions must wait for a standby acknowledgment.
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.

How we build

  • We set synchronous_standby_names and synchronous_commit on a lab cluster that matches your topology before any production change.
  • We measure write latency on representative workloads so you see the commit cost before choosing a quorum size.
  • We test primary and standby failures, including a standby loss that blocks commits, and record the observed behavior.

How we hand over

  • You receive the configuration, the replication topology diagram and the runbook for adding, removing or replacing a synchronous standby.
  • Monitoring guidance covers replication state, sync standby status and commit wait signals your operators should alert on.
  • Your team runs a handover walkthrough and a supervised failure test so operators have seen the degraded path first hand.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after handover.
  • Retainer work can cover re-testing after PostgreSQL minor releases, topology changes and new standbys.
  • Quotes follow from the written scope, so ask for a breakdown of setup, testing, documentation and recurring support.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.