Skip to content
System Design Explorer
Company architectureadvanced

GitHub System Design

Git repositories replicated by quorum across data centres and Azure

By Ankur NayakReviewed

How GitHub stores its repositories: Spokes replicates every repository at the Git level to several file servers, commits each push to a quorum of replicas with a three-phase protocol, compares replicas with a checksum of their references, and serves reads from the nearest in-sync copy. Since 2025, replicas also live in Azure, with Blob Storage joining the quorum.

Open in Studio· edit a copy
Throughput
100B+ Git operations a day (2026)
Replicas per repo
5 (2 in Azure)
Git traffic from Azure
About half
Reads per write
100–1,000
Repositories
~70M
GitHub system design architecture diagramComponents: Git Client, Git Front Ends, Spokes, GitHub DC Replicas, Azure Replicas (Central US), Azure Blob Storage, Virtual Read Replicas, Sweepers. Connections: Git Client to Git Front Ends (push / clone); Git Front Ends to Spokes; Spokes to GitHub DC Replicas (quorum write / reads); Spokes to Azure Replicas (quorum write / reads); Spokes to Azure Blob Storage (virtual replica); Spokes to Virtual Read Replicas (reads); Virtual Read Replicas to Azure Blob Storage (objects); Sweepers to GitHub DC Replicas (place, repair, rebalance).Git ClientClientGit Front EndsLoad balancerSpokesCoordinationGitHub DC ReplicasObject storageAzure ReplicasCentral USAzure Blob StorageObject storageVirtual Read ReplicasServiceSweepersWorker

Requirements

Functional

  • Accept git push, fetch and clone over HTTPS and SSH
  • Keep several complete copies of every repository
  • Never acknowledge a push that could be lost
  • Serve reads from a nearby, up-to-date copy

Non-functional

  • Survive the loss of a server or a data centre without losing pushes
  • Keep reference updates correct under concurrent pushes
  • Scale reads, which outnumber writes 100 to 1,000 times
  • Detect and repair replicas that drift

In depth

Storing every repository more than once

GitHub's core asset is Git repositories, and losing a push is unacceptable. Since 2016 GitHub has stored repositories with a system first called DGit (Distributed Git) and later Spokes, which keeps several complete replicas of each repository and replicates at the level of Git itself. GitHub has described it in three posts: introducing DGit (2016), stretching Spokes across distant data centres (2017), and moving replicas into Azure (2026). Today GitHub serves well over 100 billion Git operations a day.

Before Spokes: pairs of file servers

GitHub originally organised its file servers in pairs: each active server had a dedicated, online spare. Replication happened below Git, at the disk-block level. Failing over to the spare required manual intervention and inevitably caused a little downtime.

DGit: replicate Git, not disks

DGit, announced in April 2016, changed the level of replication. Using properties of Git itself, DGit keeps three copies of every repository on three different servers. Writes are synchronously streamed to all three and committed only if at least two confirm success: a quorum. Every replica can serve reads, so a repository could handle nearly three times the traffic it could before. At the time GitHub hosted over 35 million repositories.

Spokes: three-phase commit and checksums

The 2017 post "Stretching Spokes" explains how the system kept working as replicas moved into widely separated data centres, with nearly 70 million repositories.

Every push goes through a proxy, which transparently replicates it to multiple file servers. Updating references, the branch and tag pointers, uses the three-phase commit protocol, with the replicas acting as a distributed lock so updates are applied in the same order everywhere. On each replica, Git acquires the necessary local reference locks and verifies that the old values are as expected and the new values make sense; if everything is fine, the tentative transaction is committed, otherwise it is rolled back entirely. Across replicas, this costs four round trips. With round trips across the continental US taking 60–80 ms, a reference update cost about a third of a second.

To know whether replicas agree, Spokes computes a checksum for each one: the exclusive-or of the hash of every (reference name, value) pair. Two replicas with the same checksum hold the same logical contents, and it can be updated incrementally. Spokes computes it after every update as an extra check that replicas are in sync.

Reads outnumber writes about 100 to 1, so where they are served matters. Spokes routes reads to the closest replica that is in sync.

Into Azure

GitHub's October 2026 post, "The bridge to agent-scale Git infrastructure", describes the biggest change since. Starting in August 2025, GitHub copied 99.99999% of its repositories to Azure, in the Central US region about 1,000 miles from its own data centres (around 25 ms per round trip). Most repositories now have five replicas, two of them in Azure, and Azure serves about half of Git traffic.

Two ideas from that post extend the design:

  • Object storage in the quorum. Once a repository's data is durably stored in Azure Blob Storage, Blob Storage becomes a member of the quorum, a special one called a virtual replica. Separate virtual read replicas, backed by object storage, serve reads without joining the write quorum.
  • Per-reference quorums. Each write has held a repository-wide lock until it commits, so busy repositories serialise all their pushes. GitHub is changing the scope of the quorum from the whole repository to individual references; in testing, writes to different references saw 3–4x higher throughput at lower latency.

The post also notes that Spokes has grown well beyond a quorum coordinator: it is a routing and load-balancing layer, with background systems called sweepers that handle placement, repair and rebalancing between storage nodes. A quorum needs only a majority to commit, but it waits for every healthy replica to respond, up to a timeout, so slow replicas delay writes rather than falling behind.

Failures

When a file server fails, every repository on it still has other replicas, writes still reach a majority, and reads go elsewhere; DGit's announcement describes creating new replicas on other servers to replace lost ones. Distance is the other recurring challenge: each round trip to a far replica adds latency to every reference update, which is why the four-round-trip protocol, and now per-reference quorums, matter so much.

The trade-offs

Replicating at the Git level makes every replica useful for reads and makes replicas comparable by their references, but Spokes must understand Git. Quorum commits keep a slow or failed replica from blocking pushes, at the cost of detecting and repairing replicas that drift. Three-phase commit keeps references consistent across replicas but costs several round trips to distant ones. And adding object storage as a replica gives durability and read capacity without more full file servers, while adding a quorum member that behaves differently from the rest.

Compare with Dropbox, which stores immutable blocks instead of whole repositories, and Amazon S3, the archetypal object store.

What to take into an interview

  • Replicate at the application level when it lets every copy serve reads
  • Commit writes at a majority quorum; serve reads from the nearest in-sync replica
  • Use a cheap checksum to verify replicas agree after every update
  • Count round trips: they dominate write latency across distant data centres
  • Narrow lock and quorum scope (repository → reference) to raise write throughput
  • Consider object storage as a durable, cheap replica

Components

Git Client

Client. Runs git push, fetch and clone over HTTPS or SSH.

Git Front Ends

inferred

Load balancer. Terminate HTTPS and SSH and hand Git operations to Spokes. GitHub's posts don't describe this tier.

Spokes

Coordination. GitHub's system for storing multiple replicas of each repository, replicating at the Git application level. Every push goes through a proxy that replicates it to the replicas and commits by quorum; reads are routed to the closest in-sync replica. It has grown into a routing and load-balancing layer too.

Why: Replicating Git operations, not disk blocks, lets every replica serve traffic and makes replicas comparable by their references.

Building block: Quorum Replication, Replication

Spokes Proxy

Service. Receives the push and coordinates the update on every replica.

Replica A

Object storage. A file server holding a complete copy of the repository.

Replica B

Object storage. Another complete copy, possibly in a distant data centre.

Replica C

Object storage. A third copy; a majority must agree for the update to commit.

Spokes Checksums

Monitoring. Each replica's checksum is the XOR of the hashes of its (reference name, value) pairs; equal checksums mean equal references.

GitHub DC Replicas

Object storage. File servers in GitHub's own data centres, each holding complete copies of repositories.

Azure Replicas

Central US

Object storage. Since August 2025, a copy of 99.99999% of repositories lives in Azure too; most repositories have two of their five replicas there, and Azure serves about half of Git traffic. Azure is about 1,000 miles from GitHub's data centres, around 25 ms per round trip.

Azure Blob Storage

Object storage. Durable object storage that joins the quorum as a special member, a 'virtual replica', once repository data is stored there.

Building block: Object Storage

Virtual Read Replicas

Service. Read-serving replicas backed by object storage that don't take part in the write quorum, adding read capacity cheaply.

Sweepers

Worker. Background systems in Spokes that handle repository placement, repair and rebalancing between storage nodes. When a file server goes offline, new replicas are created on other servers.

Request flows

git push

  1. A developer pushes a new commit to main.
  2. The push reaches Spokes, which coordinates all the repository's replicas.
  3. Objects and the reference update go to the replicas in GitHub's data centres.
  4. The same update goes to the replicas in Azure.
  5. Blob Storage counts toward the quorum as a virtual replica once the data is durable there.
  6. Once a majority has committed the new reference value, the push succeeds.

git clone from the nearest copy

  1. A CI job clones a popular repository.
  2. Spokes picks the closest replica whose checksum shows it is in sync.
  3. The read can be served by a virtual read replica backed by object storage.
  4. Objects stream from Blob Storage.
  5. The clone completes without touching the write quorum.

Failure scenarios

What if: a file server dies?

Every repository has several replicas and writes need only a majority, so pushes keep committing and reads go to other in-sync replicas. Before DGit (2016), file servers ran as active/spare pairs and failover needed manual intervention with a little downtime.

User impact: None.

  • Quorum writes
  • Reads from any in-sync replica
  • Sweepers re-create lost replicas

What if: replicas are far apart?

Every network round trip to a distant replica adds latency, and a reference update takes several. GitHub is narrowing the quorum from the whole repository to individual references, so pushes to different references don't wait for each other; in testing this gave 3–4x higher throughput.

User impact: Slower pushes to very busy repositories without the change.

  • Per-reference quorums
  • Keep the quorum to a majority, not all replicas

Trade-offs

Replicate Git, not disks

Replicate at the Git application level through a proxy instead of block-level disk replication.

Pros
  • Every replica is usable for reads
  • Replicas are comparable by their references
Cons
  • Spokes must understand Git operations

Quorum commits

Acknowledge a push once a majority of replicas commit it.

Pros
  • A slow or failed replica doesn't block pushes
  • No acknowledged push is lost if a minority fails
Cons
  • Lagging replicas must be detected and repaired

Three-phase commit for references

Update references on replicas with a three-phase protocol.

Pros
  • Replicas agree on every reference's value
Cons
  • Four round trips to distant replicas per update

Object storage as a replica

Let Azure Blob Storage join the quorum as a virtual replica and serve reads from virtual read replicas.

Pros
  • Durability and read capacity without more full file servers
Cons
  • A special quorum member with different behaviour to reason about

Frequently asked questions

How does GitHub store repositories?

With Spokes, which keeps several complete replicas of each repository on different file servers, now in GitHub's data centres and in Azure. Pushes go through a proxy that updates every replica and commits once a majority agree; reads go to the nearest in-sync replica.

What is GitHub Spokes?

Spokes, first announced as DGit (Distributed Git) in 2016, is GitHub's replication system for Git repositories. It replicates at the Git level, uses three-phase commit for reference updates, compares replicas with a checksum of their references and routes reads to in-sync replicas.

How many copies of a repository does GitHub keep?

DGit started with three copies on three servers in 2016. In 2026 GitHub says most repositories have five replicas, two of them in Azure, chosen to balance durability, availability and scale.

What is the Spokes checksum?

A per-replica value equal to the exclusive-or of the hashes of every (reference name, value) pair in the repository. Two replicas with the same references have the same checksum, so Spokes can cheaply check that copies agree.

Building blocks used

Sources