Primary-Mirror Distribution Strategies

This document describes the mirror distribution strategies used in the YMatrix database system.

When deploying a YMatrix database system, mirror segments (Mirror) can be configured on hosts.

  • Functionality:
    • If a primary segment (Primary) fails, the Mirror allows query processing to continue using the backup segment.
    • Mirrors stay synchronized with their corresponding Primaries through transaction log replication.
  • Best Practice:
    • Each Mirror segment instance must be deployed on a different host than its corresponding Primary to avoid single-point-of-failure risks.

Note!
Enabling mirroring is strongly recommended in production environments.

1 Greenplum Mirror Distribution Strategies

Before discussing YMatrix's mirror distribution strategy, this section provides background knowledge based on Greenplum’s mirror configurations. Greenplum supports two standard mirroring configurations: Group Mirroring and Spread Mirroring, with Group Mirroring being the default.

1.1 Spread Mirroring

In spread mirroring, mirrors from each host are distributed across the remaining hosts in the cluster. This configuration requires that the number of hosts in the cluster exceeds the number of primary segments per host.
To ensure even distribution, the total number of independent hosts must be greater than the number of segment instances per host.

1.2 Group Mirroring

In group mirroring, all mirrors for primary segments on a single host are grouped together and placed on another host within the cluster.
This is the default mirror distribution strategy in Greenplum.

2 YMatrix Mirror Distribution Strategy

YMatrix uses Ring Mirroring as the default strategy. With at least two hosts, the primary segment sequence on one host is treated as a one-dimensional tape, folded in half. Starting from the middle segment ID after folding, mirrors are placed clockwise and evenly distributed across other hosts.

When expanding the cluster by adding new primaries, the existing mirrored ring remains unchanged; instead, a new mirror ring is initiated.
This is the default mirror distribution strategy in YMatrix.

This strategy balances the advantages and disadvantages of the previous two methods, offering a compromise between them. The comparison among the three strategies is shown in the table below:

Spread Group Ring
System Stability Unstable Stable Moderately Stable
Load Balancing Balanced Unbalanced Moderately Balanced

Note!
If you wish to use a mirror distribution strategy other than Ring Mirroring in YMatrix, you can achieve this through custom configuration using mxaddmirrors.