Skip to main content

PostgreSQL cluster fault tolerance

By default, a PostgreSQL Managed Database cluster consists of one master node. To ensure cluster fault tolerance, you need to add replicas to it. In multi-node clusters, one node will be the master node, while the others will be replicas.

note

For example, if you have created a three-node cluster, the cluster will have one master node and two replicas. If you add more nodes, they will be replicas.

The node allocation type in a cluster depends on the availability of replicas in the cluster, the type of pool where the cluster is located, and the number of segments in the pool.

Master node

By default, a cluster consists of one primary node — the master node. When connected to the master node, all operations are available: reading (SELECT) and writing (INSERT, UPDATE, DELETE, and others).

All data changes on the master node are duplicated on the replicas. The replication process does not affect the operation of the replicas or the master node.

Replicas

Replicas are full copies of the master node. They are available only for reading data (SELECT). In PostgreSQL Managed Database clusters, one replica is always synchronous, and all subsequent replicas are asynchronous.

Having replicas in a cluster ensures its fault tolerance — if the master node stops working, its role will be taken over by one of the replicas, and the cluster will continue to operate normally. When the master node is restored, it will take on the role of a replica. At this point, the master node address will change.

For a cluster with replicas, an SLA applies — we guarantee 99.95% write availability and 99.99% read availability.

If there are no replicas in the cluster, it will be unavailable until the master node is restored. Data will not be lost.

We recommend creating fault-tolerant clusters with replicas or adding replicas to existing clusters.

Node allocation

The node allocation type depends on whether the cluster has replicas, the type of pool where the cluster is located, and the number of segments in the pool:

  • Single-Segment — in one segment of a single-AZ pool. Applicable to:

    • clusters without replicas;
    • clusters with replicas that are located in pools with only one segment;
    • clusters with replicas in HighFreq and Dedicated configuration lines;
note

For example, you have created a three-node cluster (one master node and two replicas) in a HighFreq configuration line in the ru-2 pool. All nodes will be placed in one segment of the ru-2c pool.

  • Multi-Segment — in different segments of a single-AZ pool. Applicable to clusters with replicas located in pools with multiple segments. Segments are located in different racks of the same data center. Nodes are distributed across segments sequentially;
note

For example, you have created a four-node cluster (one master node and three replicas) in the ru-1 pool. The first three nodes will be placed sequentially in segments ru-1a, ru-1b, and ru-1c of the pool. The fourth node will be placed in segment ru-1a. If you add a fifth node, it will be placed in segment ru-1b of the pool.

  • Single-AZ — in one segment of a multi-AZ pool. Applicable to clusters without replicas in the ru-6 pool. If you add a replica to a cluster, the node allocation type changes to Multi-AZ;

  • Multi-AZ — in different segments of a multi-AZ pool. Applicable to clusters with replicas in the ru-6 pool. Each pool segment is located in a separate data center. Nodes are distributed across segments sequentially.

note

For example, you have created a four-node cluster (one master node and three replicas) in the ru-6 pool. The first three nodes will be placed sequentially in segments ru-6a, ru-6b, and ru-6c of the pool. The fourth node will be placed in segment ru-6a. If you add a fifth node, it will be placed in segment ru-6b of the pool.

You can view the list of pools and segments in the Servercore Infrastructure table of the Locations: countries, regions, availability zones, pools, and data center addresses guide.

Change the number of replicas

You can increase or decrease the number of replicas. When changing the number of replicas, the cluster continues to work.

  1. In the Control panel, on the top menu, click Products and select Managed Databases.
  2. Open the Active tab.
  3. Open the cluster page → Settings tab.
  4. Click Change configuration.
  5. In the Fault tolerance block, in the Number of nodes field, specify the new number of replicas. If there are no free addresses in the subnet to which the cluster is connected, you cannot add a replica — each new replica occupies a new address in the subnet.
  6. Click Save.