MySQL Group Replication: Single-Primary vs Multi-Primary

This article explains the core differences between single-primary and multi-primary modes in MySQL Group Replication. It covers how each mode manages write operations, handles transaction conflicts, impacts application design, and behaves during node failures, allowing you to choose the best configuration for your database infrastructure.

What is Single-Primary Mode?

In single-primary mode, MySQL Group Replication designates only one member of the group as the primary node. This primary node is the only member that configures itself to accept write operations (read-write mode). All other members in the group are automatically configured as read-only.

If the primary node fails, the remaining members automatically elect a new primary. This election is based on factors such as the MySQL server version of the members and their UUIDs. Single-primary mode is the default configuration for MySQL Group Replication because it behaves similarly to traditional master-slave replication, making it highly compatible with existing applications.

What is Multi-Primary Mode?

In multi-primary mode, every member of the group can accept write operations simultaneously. There is no single primary node; instead, all nodes operate in read-write mode.

When a transaction is executed on one node, it must be agreed upon by the entire group before it commits. Because writes can occur on different nodes at the same time, MySQL Group Replication uses an optimistic replication model. Transactions are checked for conflicts against other concurrent transactions across the group, and any conflicting transactions are rolled back.

Key Differences

1. Write Allocation and Load Balancing

2. Conflict Detection and Resolution

3. Feature Limitations and Data Safety

4. Application Complexity

Summary of Differences

Feature Single-Primary Mode Multi-Primary Mode
Active Write Nodes One All
Default Mode Yes No
Write Conflict Risk None High (requires conflict resolution)
Handling of Conflicts N/A First-committer-wins (aborts losing transaction)
DDL Limitations Standard MySQL rules Strict (no concurrent DDL on different nodes)
Foreign Keys with Cascade Fully supported Not recommended