← 回總覽

从分钟级到秒级:Uber 通过共识架构提升 MySQL 集群可用性

📅 2026-03-11 22:15 Leela Kumili 软件编程 4 分鐘 4938 字 評分: 78
MySQL 数据库架构 高可用性 共识协议 Uber 工程
📌 一句话摘要 Uber 将其庞大的 MySQL 集群迁移到基于共识的组复制(Group Replication)架构,在确保强一致性的同时,将故障转移时间从分钟级缩短至 10 秒以内。 📝 详细摘要 本文详细介绍了 Uber 对其 MySQL 集群进行的基础设施改造,从传统的带有外部故障转移的异步复制转向 MySQL 组复制(MGR)。通过将基于 Paxos 的共识协议直接嵌入数据库层,Uber 实现了自动主库选举,并大幅缩短了故障期间的写入不可用时间。新架构利用三节点核心进行共识,并辅以额外的只读副本进行扩展。为了大规模管理这一架构,Uber 开发了自动化控制平面用于集群上线和重平衡,

Uber redesigned its MySQL infrastructure to improve cluster uptime, replacing external failover with MySQL Group Replication(MGR). Applied across thousands of clusters, the change reduces failover from minutes to seconds while maintaining strong consistency. The redesign began by introducing consensus replication to remove external dependencies, and was scaled fleet‑wide with automated onboarding, node management, rebalancing, and safeguards to ensure quorum and operational reliability.

Previously, Uber ran MySQL clusters in a single-primary, asynchronous replica model. External systems detected failures and promoted replicas, resulting in failover times measured in minutes. To reduce downtime and improve reliability, Uber adopted MySQL Group Replication, a Paxos-based consensus protocol. The new architecture embeds consensus within the database itself, forming a three-node MGR cluster. One node serves as primary for writes, while the other two secondaries participate in consensus without accepting direct writes. This ensures that all nodes maintain up-to-date data and can automatically elect a new primary if needed.

Uber Engineering emphasized in a LinkedIn post:

> At Uber, high availability is non-negotiable.

Scalable read replicas fan out from the secondaries, separating read scaling from write availability while preserving fault tolerance. Flow control within MGR monitors transaction queues on each secondary and signals the primary to pause, or throttle writes as needed, preventing nodes from falling behind. This mechanism avoids replication inconsistencies, reduces write downtime during failover, and prevents errant GTIDs from propagating outside the cluster.

!Image 1/filters:no_upscale()/news/2026/03/uber-mysql-uptime-consensus/en/resources/3consensus-1772310053991.jpeg)

_Architecture of a consensus-based MySQL cluster (Source: Uber Blog Post)_

Benchmarking revealed trade-offs with the new design, showing a slight increase in write latency of hundreds of microseconds compared to asynchronous replication, but a dramatic reduction in total write unavailability during primary failures from minutes to under 10 seconds, including primary election and routing updates. Read latencies remained consistent since local replica performance matched the legacy model.

Uber scaled the architecture using an automated control plane for cluster onboarding, offboarding back to legacy replication, and rebalancing during topology changes. Workflows handle both graceful and ungraceful node replacements, and configurations such as group_replication_unreachable_majority_timeout and single-leader mode protect against split-brain and minority partitions. Automated topology health analysis dynamically adds new nodes when a group drops below quorum and removes excess nodes to reduce overhead. Downstream replicas are repointed during node deletion, with optional backlog application blocking to maintain strict external consistency.

!Image 2/filters:no_upscale()/news/2026/03/uber-mysql-uptime-consensus/en/resources/1rebalance-1772309210665.jpeg)

Rebalance consensus cluster workflow _(Source: Uber Blog Post)_

Uber engineers say implementing MySQL Group Replication at scale revealed MGR plugin using performance_schema.memory/group_replication, and careful handling of group_replication_bootstrap_group to prevent split-brain scenarios. Single-primary mode was selected over multi-primary for simplicity and operational predictability, as multi-primary introduces higher conflict potential and requires robust conflict resolution for transactional ordering. The combination of consensus-based replication, automated workflows, and scalable read replicas enables high availability, strong consistency, and reduced manual intervention, providing a foundation for Uber’s fleet-scale MySQL infrastructure.

查看原文 → 發佈: 2026-03-11 22:15:00 收錄: 2026-03-12 00:01:10

🤖 問 AI

針對這篇文章提問,AI 會根據文章內容回答。按 Ctrl+Enter 送出。