Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
    • Cloud Interconnect
    • Cloud Backup
    • Cloud Registry
    • Yandex AI Studio
    • Compute Cloud
    • Object Storage
    • Managed Service for Kubernetes®
    • Yandex BareMetal
    • Smart Web Security
    • Security Deck
    • Managed Service for PostgreSQL
    • Managed Service for ClickHouse®
    • Monium
    • Cloud CDN
    • Network Load Balancer
    • Virtual Private Cloud
    • Cloud DNS
    • Application Load Balancer
    • Yandex Cloud Video
    • Stackland
    • Yandex Cloud Router
    • Yandex Managed Service for Trino
    • Managed Service for MySQL®
    • Managed Service for Valkey™
    • Managed Service for Apache Spark™
    • Yandex StoreDoc
    • Managed Service for OpenSearch
    • Managed Service for Apache Kafka®
    • Data Transfer
    • Yandex MPP Analytics Engine for PostgreSQL
    • Yandex Managed Service for Apache Airflow®
    • Data Processing
    • Yandex MetaData Hub
    • Managed Service for YDB
    • Managed Service for Sharded PostgreSQL
    • Managed Service for YTsaurus
    • Yandex WebSQL
    • DataLens
    • Yandex Search API
    • SpeechSense
    • SpeechKit
    • DataSphere
    • Vision OCR
    • Translate
    • Yandex Identity Hub
    • Key Management Service
    • Certificate Manager
    • Yandex Lockbox
    • Audit Trails
    • SmartCaptcha
    • Cloud Desktop
    • SourceCraft Code Assistant
    • Container Registry
    • Managed Service for GitLab
    • Managed Service for Prometheus®
    • Cloud Functions
    • API Gateway
    • Yandex Cloud Postbox
    • Message Queue
    • Serverless Integrations
    • IoT Core
    • Data Streams
    • Serverless Containers
    • Cloud Notification Service
    • Yandex Query
    • Identity and Access Management
    • Yandex Cloud Console
    • Resource Manager
    • Yandex Cloud Billing
    • Yandex Cloud Quota Manager
    • Cloud Apps
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Managed Service for PostgreSQL
  • Getting started
    • Resource relationships
    • Planning a cluster topology
    • High availability clusters
    • Networking in Managed Service for PostgreSQL
    • Quotas and limits
    • Storage in Managed Service for PostgreSQL
    • Backups
    • Assigning roles
    • Managing connections
    • Load balancer for hosts
    • Replication
    • Maintenance
    • Supported clients
    • PostgreSQL settings
    • Indexes
    • SQL command limits
    • Upgrading the PostgreSQL major version
    • PostgreSQL versioning policy
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Managing replication
  • Automatic management of replication streams
  • Manual management of replication streams
  • Write sync and read consistency
  • Logical decoding
  • Use cases
  1. Concepts
  2. Replication

Replication in Managed Service for PostgreSQL

Written by
Yandex Cloud
Updated at July 28, 2026
View in Markdown
  • Managing replication
    • Automatic management of replication streams
    • Manual management of replication streams
  • Write sync and read consistency
  • Logical decoding
  • Use cases

Managed Service for PostgreSQL clusters use quorum-based synchronous replication:

  1. Master host is selected from among cluster hosts, while all other hosts become replicas.

  2. A transaction is considered successful only if it is confirmed by the master host and the quorum of replicas. The quorum is the half of all replicas in a cluster. Replicas for the quorum are selected randomly (quorum replicas).

    If there is an odd number of replicas, the value is rounded down, except when there is only one replica. For example, in a cluster with 17 replicas, the quorum requires a minimum of eight replicas, while in a single-replica cluster, the quorum is one.

Warning

Replicas with a manually specified replication source can neither become master hosts nor be part of a quorum.

The number of quorum replicas is updated every time the number of available cluster hosts changes, e.g., when hosts are added or deleted as well as during scheduled or unscheduled maintenance. When you add a host, it is first synchronized with the master and only then can become part of the quorum.

For more information on how replication works in PostgreSQL, see the PostgreSQL documentation.

Managing replicationManaging replication

To ensure data integrity, the cluster supports automatic replication management, where each replica host receives a replication stream from the master host. If you need to, you can specify the replication source manually.

In a cluster, you can combine automatic and manual management of replication streams.

Automatic management of replication streamsAutomatic management of replication streams

Once you create a PostgreSQL cluster with multiple hosts, it contains one master host and replicas. Replicas use the master host as a replication source.

Specifics of automatic replication in Managed Service for PostgreSQL:

  • When the master host fails, its most recent replica becomes the new master.
  • When the master changes, the replication source for all replica hosts automatically switches to the new master host.

Manual management of replication streamsManual management of replication streams

When you manage replication streams manually, a cluster host other than the master will serve as the replication source for a replica. If a manually specified replication source becomes unavailable, the replica will automatically switch to the current master while still being treated as a replica with a manually specified replication source. Once the replication source is restored, the replica will switch back to it.

This way, in a PostgreSQL cluster with complex topology, you can configure cascading replication during which some of the replicas use other cluster hosts as the replication stream source. The replication stream for such source hosts can be managed both automatically, using the Managed Service for PostgreSQL tools, and manually.

Warning

Replicas, for which the replication source is specified manually, cannot:

  • Become a master host when the previous one is changed automatically or manually.
  • Be part of quorum replication.
  • Be selected as most recent replicas when using a special FQDN.

A replica with a manually specified replication source cannot confirm a write operation. Its data will be regarded as obsolete if the write operation was made to other replicas and the quorum confirmed the transaction. As the replica’s lag grows, its WAL will be automatically overwritten with the new data from the replication source.

Write sync and read consistencyWrite sync and read consistency

Synchronization of data writes in PostgreSQL is ensured by the synchronous_commit parameter that manages syncing the write-ahead log (WAL). The default value is synchronous_commit = on. In this case, a transaction is commited only if the WAL is written to both the master disk and each quorum replica disk.

Depending on the number of replicas in the cluster, the following behavior scenarios are possible:

  • In a cluster with one replica, this replica will constitute the quorum, and manual replication stream management is unavailable. If the replica fails, write transactions will await confirmation until it is restored in the cluster.
  • In a cluster with two replicas, a transaction is committed if the WAL is written to the disk of the quorum replica. If it fails, the quorum will consists of the remaining replica unless it has a replication source specified. In this case, the results of queries to the master host will not change.
  • In a cluster with an odd number of replicas N > 1, the quorum consists of N-1 / 2 replicas. For other replicas, you can set a replication source manually.
  • In a cluster with an even number of replicas N > 2, the quorum consists of N / 2 replicas. For other replicas, you can set a replication source manually.

To ensure ongoing consistency of data reads between the master and quorum replica, set synchronous_commit = remote_apply in the cluster settings. With this parameter value, a data write is not considered successful until the quorum replica applies the changes from the WAL. In this case, the read operation performed on the master and quorum replica returns the same result.

The downside is that the write operations to the cluster will take longer. If the master and the quorum replica are located in different availability zones, the transaction confirmation latency cannot be less than the round-trip time (RTT) between data centers. This will degrade cluster performance if writing data to a single thread with the AUTOCOMMIT mode on.

To enhance performance, write data to multiple threads whenever possible, disable AUTOCOMMIT, and group queries within a transaction.

Logical decodingLogical decoding

Managed Service for PostgreSQL clusters support logical decoding to stream DB changes to external services. For instance, it may be used as a way to change data capture (CDC).

Information about DB changes is sent to a replication slot in WAL format, where it is decoded to a format readable by an external service using an output plugin.

Managed Service for PostgreSQL supports the following WAL plugins:

  • test_decoding: Converts WAL data into text.
  • wal2json: Converts WAL data into JSON format.
  • pgoutput: Transforms data read from WAL to the logical replication protocol.

Replication slots can be created by users with the mdb_replication role.

Use casesUse cases

  • Migrating a database from a third-party PostgreSQL cluster to Managed Service for PostgreSQL
  • Migrating data from Yandex Managed Service for MySQL® to Managed Service for PostgreSQL using Yandex Data Transfer
  • Migrating data from Managed Service for PostgreSQL to Yandex Managed Service for MySQL® using Yandex Data Transfer
  • Migrating a database from Managed Service for PostgreSQL
  • Asynchronously replicating data from PostgreSQL to ClickHouse®

Was the article helpful?

Previous
Load balancer for hosts
Next
Maintenance
© 2026 Direct Cursus Technology L.L.C.