在过去的一年里,随着 Git 流量的指数级增长,GitHub 上 99.99999% 的 Git 存储库开始同时存在于两个地方:我们自己的数据中心和 Azure。其余的存储库是平台上最繁忙的那些,它们受到阻碍的原因只有一个:25 毫秒的往返延迟。
在之前的博客文章中,我们阐述了下一代存储架构背后的两大原则:
最小化协调
将存储与计算解耦
在这篇文章中,我们将探讨从旧设计到新设计的即时桥梁。我们将讨论如何通过对法定人数序列化写入方式的更改,使最繁忙的存储库进入 Azure,以及这一步骤如何为保持自身无持久状态的副本打开大门。
我们是如何走到这一步的
迁移的时机和形态是由代理化转变驱动的:流量迅速增长、我们数据中心及所在地理区域电力容量的硬性上限,以及物理供应链的限制。在迁移初期,所有可能扩展后的剩余容量给了我们足够的时间安全地进行迁移,但不足以让我们慢慢来。
虽然我们已经为在云基础设施上扩展 Git 的新架构方法进行了原型设计,但在如此增长的压力下,同时更改存储架构和托管平台带来的风险太高。鉴于我们的规模以及该服务对社区的重要性,我们需要仔细安排工作顺序:先迁移数据,待数据到位后再演进架构。
Git 操作属于 Tier 0 级服务:它们是 GitHub 的核心功能,GitHub 中的几乎所有内容都依赖于存储库数据。这意味着数据、服务以及每一个依赖项都必须首先迁移。第一个存储库副本于 2025 年 8 月落地 Azure 的 Central US 区域。如今,大多数存储库在 Azure 中拥有五个副本中的两个,Azure 承载了约一半的 Git 流量。在大部分时间里,Azure 吸收了我们增长的部分,而我们自己的数据中心则保持稳定。
在迁移期间,流量跟随数据移动。大多数存储库拥有五个副本,以平衡持久性、可用性和规模。为了最小化读取延迟,Spokes 使用首选路由将流量引导至与请求位于同一区域和可用区的副本。随着副本迁移到 Azure,能够从 Azure 服务的流量份额随着每一个新副本的到来而增长,直到最后一个副本到达,旧区域完全停止接收请求。每个存储库都会经历这一过程:
不落下任何一个存储库
那么,剩余的 0.00001% 的存储库怎么办?
在我们当前的架构中,托管在多个区域的存储库具有较低的写入吞吐量上限。Spokes 的法定人数只需要多数派即可提交写入,但它会等待每个健康的副本响应(直到超时)后才继续下一步,因此慢速副本会延迟每一次写入,而不是落后于其他副本。在实践中,这意味着最慢的健康副本决定了每次写入的延迟,并且由于每次写入在提交之前都会持有存储库范围的锁,它还决定了吞吐量上限。一旦某个副本位于目标 Azure 区域,它距离我们的数据中心约 1,000 英里,使得每次网络往返约为 25 毫秒,而一次写入需要多次往返。一个已经接近其吞吐量上限的存储库无法在每次串行写入中吸收这种延迟;随着每一次推送,它会落后得更多。
这正是我们第一原则——最小化协调——发挥作用的地方。具体针对这种情况:不要序列化那些不需要序列化的内容。Git 的一致性要求适用于每个引用(reference)。一旦服务器接受了对某个引用的更新,客户端此后不应再看到旧值,只能看到该值或更新后的值。无论更新是快进、强制推送还是删除,这一原则都适用。但在大多数情况下,对不同引用的更新彼此不依赖,可以独立应用。
因此,我们将法定人数(quorum)的范围从整个仓库调整为单个引用。
在整个引用更新期间(包括往返通信)持有仓库级锁,会将法定人数转化为一个单一的、无序的请求队列,且同一时间仅允许一个写入操作进行。队列中的每个写入操作耗时取决于最慢的健康副本。随着写入速率的增加,队列也会随之增长,且每个写入操作的等待时间会比前一个更长。
通过按引用进行序列化,只有针对共享引用发生竞争的写入操作才需要互相等待。在实际场景中,大多数对仓库的写入操作涉及不同的引用——例如,代理和开发者向各自的分支推送代码——因此它们不再互相等待。每个写入操作仍会经历跨区域延迟,但针对不同引用的写入操作可以同时进行。这消除了仓库层面的单一瓶颈。我们可以通过在相似负载下并排比较这两种方法,来直观地展示排队和超时是如何累积的:
这些变更使仓库的写入吞吐量上限大致与同时写入的引用数量成正比,并使最后剩余的仓库得以迁移至 Azure。在模拟真实流量的内部测试中,针对不同引用的写入操作始终实现了低延迟下 3–4 倍的更高吞吐量。
独立扩展读取能力
大多数仓库的读取负载远重于写入负载,每进行一次写入通常伴随 100 到 1,000 次读取。目前,读取和写入操作访问相同的副本,因此它们争夺相同的资源,无法独立扩展。
将存储与计算分离改变了这一状况。一旦仓库数据持久化存储在 Azure Blob Storage 中,并在每次传入写入时更新,我们就可以开始将读取流量从写入法定人数中解耦,并独立扩展各自所需的计算资源。例如,读取操作比目前获得的缓存更多内存会更有益,但这些内存也用于压缩(compaction)。一旦它们分离,每一项都可以拥有自己的配置。
第一步是将对象存储作为法定人数的成员加入,但这是一个特殊的成员,我们称之为虚拟副本(virtual replica)。代表它的计算节点是我们第一个完全临时的节点。它充当通往对象存储的桥梁,流式传输传入的写入操作,并不服务任何读取请求。由于它是法定人数的成员,直到写入在对象存储中确保持久化后,才会确认该写入。
这为每次写入增加了一点延迟,但就像跨区域往返通信一样,按引用序列化防止其成为吞吐量瓶颈。虚拟写入副本还将针对不相交引用的事务合并为一组对对象存储的网络 I/O 操作,因此繁忙的仓库只需为许多并发写入支付一次往返费用,而不是每次写入都支付一次。目前,虚拟写入副本还处理压缩,读取副本继承压缩后的状态。
随着虚拟写入副本就位,我们可以按需扩展仓库所需的任意数量的虚拟读取副本。每个读取副本从 Azure Blob Storage 预热其缓存,并开始接收读取流量,而无需加入法定人数,它将对象存储作为事实来源,并在后台将其本地状态与之进行协调。
这一步解锁了大规模的读取扩展能力。在内部测试中,我们的分布式负载测试工具常规性地发现当前架构存在吞吐量上限。而在面对虚拟读取副本时,该测试工具首先达到了自身的限制。此外,还有一些挑战需要在后续步骤中解决:
虚拟读取副本最初在后台与对象存储进行协调,这使其适合某些读取工作负载,但并不适合所有工作负载。为了服务每种类型的读取操作,需要将这种协调过程内联化,仅获取自副本上次同步以来发生变化的引用状态和数据。
尽管我们通过转向每引用(per-reference)模型逐步提高了写入吞吐量,但法定人数(quorum)仍然是进一步增加吞吐量的限制因素。
我们如何进一步提升写入吞吐量?
接下来是什么
今天的 GitHub 建立在 Spokes 法定人数的基础之上,多年来,Spokes 已不仅仅是一个法定人数协调器。它还是一个智能路由和负载均衡层、一个统一 API,内部客户端通过该 API 访问并处理仓库数据,日均操作量超过 1000 亿次,以及一组我们称之为“清理程序(sweepers)”的后台系统,用于处理存储节点之间的仓库放置、修复和重新平衡。
Spokes 服务伞下的大多数功能同样适用于新架构和现有架构。但我们同时也认识到,曾将 GitHub 推向十亿个仓库规模的提交协议,无法将其带向下一个十亿及更远的未来。
我们尚未完成。随着这些步骤的实施,下一个瓶颈是写入吞吐量。每次写入仍需等待持有仓库完整副本的副本节点,但实际上,写入操作中的极少部分需要被排序。Git 对象是不可变的,且由其内容命名,因此可以在无需各方达成一致的情况下存储它们。剩下的部分很小,而难点在于如何尽可能快地对其进行排序,同时不将瓶颈转移到其他地方。在白板上设计这样的方案是一回事,而在开发者及智能体全天候写入的十亿个仓库之下实现它则是另一回事。要达到这一目标迫使我们重新思考二阶效应,例如持久化引用状态的存储位置,以及压缩和垃圾回收如何扩展。
智能体流量并未放缓,随着每一步措施的落地,仓库获得了更多的余量,而无需等待最终状态的到来。
下周预告:在 GitHub Universe 大会上以及本系列的最后一篇文章中,我们将带您一览这一最终状态,它如何提升写入吞吐量,我们为此必须解决的二阶问题,以及为什么在架构栈的某处仍然存在一个(小型)共识组。
感谢 Brian Celenza 对本文的贡献。
Over the past year, while Git traffic grew exponentially, 99.99999% of the Git repositories on GitHub began living in two places at once: our own data centers and Azure. The rest are among the busiest on the platform, and they’re held back by just one thing: a 25ms round trip.
In an earlier blog post , we laid out the two principles behind our next-generation storage architecture:
Minimize coordination
Decouple storage from compute
In this post, we’ll look at the immediate bridge between our old design and our new one. We’ll talk about how a change to the way our quorum serializes writes gets the busiest repositories into Azure, and how that same step opens the door to replicas that keep no persistent state of their own.
How we got here
The timing and shape of the move were driven by the agentic shift: rapidly growing traffic, a hard ceiling on the power capacity of our data centers and the surrounding geographical region, and physical supply chain constraints. At the beginning of our migration, the remaining capacity with all possible expansion gave us enough time to migrate safely, but not enough to do it slowly.
While we had prototyped new architectural approaches for scaling Git on cloud infrastructure, changing the storage architecture and the hosting platform at the same time, under that growth, carried too much risk. Given our scale and how critical the service is to the community, we needed to sequence the work carefully: move the data first, then evolve the architecture once it arrived.
Git operations are a Tier 0 service: they’re a core function of GitHub, and nearly everything in GitHub depends on the repository data. That meant the data, services, and every dependency had to move first. The first copy of a repository landed in Azure’s Central US region in August 2025. Today, most repositories have two of their five replicas in Azure, and Azure serves about half of Git traffic. For most of that time, Azure absorbed our growth while our own data centers held steady.
During the migration, traffic follows the data. Most repositories have five replicas to balance durability, availability, and scale. To minimize read latency, Spokes uses preferential routing to direct traffic to a replica in the same region and availability zone as the request. As replicas move to Azure, the share of the traffic that can be served from Azure grows with each one, until the last replica arrives and the old region stops receiving requests entirely. Every repository goes through this process:
No repository left behind
So, what about the remaining 0.00001% of repositories?
In our current architecture, a repository hosted in more than one region has a lower write throughput ceiling. Spokes’ quorum only needs a majority to commit a write, but it waits for every healthy replica to respond (up to a timeout) before moving on, so slow replicas delay every write rather than falling behind. In practice, that means the slowest healthy replica sets the latency of every write, and because each write holds a repository-wide lock until it commits, it also sets the throughput ceiling. Once a replica lives in the target Azure region, it’s about 1,000 miles from our data centers, making each network round trip around 25ms, and a write requires multiple round trips. A repository already near its throughput ceiling can’t absorb that on every serialized write; it would fall further behind with every push.
This is where our first principle, minimizing coordination, comes into play. Specifically for this case: don’t serialize what doesn’t need to be. Git’s consistency requirements apply to each reference individually. Once the server accepts an update to a reference, no client should see an older value afterward, only that value or a newer one. That holds whether the update is a fast-forward, a force push, or a delete. But in most cases, updates to different references don’t depend on each other and can be applied independently.
So, we’re changing the scope of the quorum from the whole repository to individual references.
Holding a repository-wide lock for the entire reference update, round trips included, turns the quorum into a single, unordered request queue with one write in flight at a time. Each write in that queue takes as long as the slowest healthy replica. As the write rate grows, so does the queue, and each write waits longer than the one before it.
With per-reference serialization, only writes that contend on a shared reference must wait for each other. In practice, most writes to a repository touch different references—for example, agents and developers pushing to their own branches—so they no longer wait on each other. Each write still experiences the cross-region latency but writes to different references can be in flight at the same time. That removes the single bottleneck on the repository. We can visualize how queueing and timeouts build up by comparing the two approaches side by side under similar load:
These changes raise a repository’s write throughput ceiling roughly in proportion to how many references are being written at once, and get the last remaining repositories into Azure. In internal testing with realistic traffic, writes to different references consistently saw 3–4x higher throughput at lower latency.
Scaling reads on their own
Most repositories are heavily read-skewed, with somewhere between 100 and 1,000 reads for every write. Today, reads and writes hit the same replicas, so they compete for the same resources and can’t be scaled independently.
Decoupling storage from compute changes that. Once repository data is durably stored in Azure Blob Storage and updated with each incoming write, we can begin to decouple read traffic from the write quorum, and independently scale the compute needed for each. For example, reads would benefit from far more in-memory cache than we give them today, but that memory is also needed for compaction. Once they’re separated, each gets its own configuration.
The first step is making object storage a member of the quorum, but a special one that we call a virtual replica. The compute that represents it is our first fully ephemeral node. It serves as a bridge to object storage, streaming incoming writes and serving no reads. Because it’s a member of the quorum, a write isn’t acknowledged until it’s durable in object storage.
That adds a little latency to each write, but just like the cross-region round trip, per-reference serialization keeps it from becoming a throughput bottleneck. The virtual write replica also coalesces transactions on disjoint references into a single set of network I/Os to object storage, so a busy repository pays for one round trip across many concurrent writes instead of one per write. For now, the virtual write replica also handles compaction, and read replicas inherit the compacted state.
With the virtual write replica in place, we can scale out as many virtual read replicas as a repository needs, on demand. Each read replica warms its cache from Azure Blob Storage and starts taking read traffic without joining the quorum, using object storage as the source of truth and reconciling its local state against it in the background.
This step unlocks significant read scale. In internal testing, our distributed load testing harness routinely found ceilings in the current architecture. Against virtual read replicas, the harness hit its own limits first. It also comes with a few challenges that are solved in subsequent steps:
Virtual read replicas start out reconciling with object storage in the background, which makes them a good fit for some read workloads but not all of them. Serving every kind of read requires moving that reconciliation in-line, fetching only the reference state and data that changed since the replica last caught up.
While we’ve incrementally increased write throughput by shifting to a per-reference model, the quorum remains the bounding factor for increasing further.
How can we push write throughput further?
What comes next
The GitHub of today was built on the Spokes quorum, and over the years Spokes has become much more than a quorum coordinator. It’s also an intelligent routing and load balancing layer, a unified API that internal clients use to access and transact repository data at well over 100 billion operations per day, and a collection of background systems we call “sweepers” that handle repository placement, repair, and rebalancing between storage nodes.
The vast majority of what lives under the Spokes service umbrella applies just as well to the new architecture as it does to the existing one. But we also recognize that the commit protocol that has taken GitHub to a billion repositories won’t take it to the next billion and beyond.
We’re not done yet. With these steps in place, the next limit is write throughput. Every write still waits on replicas that each hold a full copy of the repository, yet very little of a write actually needs to be ordered. Git objects are immutable and named by their contents, so they can be stored without anyone agreeing on them. What’s left is small, and the hard part is ordering it as fast as possible without moving the bottleneck somewhere else. Designing for that on a whiteboard is one thing. Doing it underneath a billion repositories that developers and agents are writing to around the clock is another. Getting there forced us to rethink the second-order effects too, like where durable reference state lives and how compaction and garbage collection scale.
Agent traffic isn’t slowing down, and each of these steps gives repositories more headroom as it lands, without waiting for the end state.
Coming next week: At GitHub Universe and in the final post in this series, we’ll take a tour through that end state, what it does for write throughput, the second-order problems we had to solve to get there, and why there’s still a (small) consensus group somewhere in the stack.
Thanks to Brian Celenza for their contributions to this post.
| 刊期 | 得分 | 排名 | 结果 |
|---|---|---|---|
| 2026-11-05 | 7.4 | 70 | 未入选 |
| 2026-11-04 | 7.4 | 74 | 未入选 |
| 2026-11-03 | 7.4 | 58 | 未入选 |
| 2026-10-26 | 7.42 | 20 | 入选 |
| 2026-10-25 | 7.66 | 30 | 未入选 |
| 2026-10-24 | 8.05 | 53 | 未入选 |
| 2026-10-23 | 8.67 | 48 | 未入选 |
| 2026-10-22 | 9.65 | 37 | 未入选 |