Skip to content
System Design Explorer
Company architectureadvanced

Cloudflare System Design

An anycast edge where every server runs every service

By Ankur NayakReviewed

How Cloudflare serves traffic from hundreds of cities: every data centre announces the same IP addresses (anycast), every server runs every service, packets pass XDP-based DoS filtering and the Unimog load balancer before reaching Pingora, a Rust proxy handling over a trillion requests a day, and configuration reaches every server within seconds through Quicksilver, a replicated key-value store.

Open in Studio· edit a copy
Users
Servers in 330 cities (2025)
Throughput
1T+ proxied requests/day (2022)
Quicksilver reads
3B+ keys/s
Quicksilver latency
90% < 1 ms
Pingora vs old proxy
~1/3 CPU & memory
Unimog cost
< 1% CPU
Cloudflare system design architecture diagramComponents: Visitor, Anycast Router (BGP + ECMP), Other Data Centres, DoS Mitigation (XDP (L4Drop)), Unimog (XDP L4 load balancer), Pingora Proxy (Rust), Customer Origin, Quicksilver, Configuration API. Connections: Visitor to Anycast Router (anycast IP); Anycast Router to Other Data Centres (if unreachable); Anycast Router to DoS Mitigation (ECMP); DoS Mitigation to Unimog; Unimog to Pingora Proxy (to chosen server); Pingora Proxy to Quicksilver (config lookup); Pingora Proxy to Customer Origin (reused connection); Configuration API to Quicksilver (write → root).VisitorClientAnycast RouterBGP + ECMPOther Data CentresCDNDoS MitigationXDP (L4Drop)UnimogXDP L4 load balancerPingora ProxyRustCustomer OriginExternal APIQuicksilverNoSQL databaseConfiguration APIAPI gateway

Requirements

Functional

  • Accept traffic for over 26 million Internet properties (2020) on shared IP addresses
  • Filter attacks, terminate TLS and proxy HTTP to customers' origins
  • Apply each customer's configuration on every server
  • Propagate configuration changes worldwide quickly

Non-functional

  • Absorb huge DDoS attacks without affecting legitimate traffic
  • Keep connections alive while servers are added or removed
  • Use CPU and memory efficiently on every machine
  • Configuration reads in microseconds to milliseconds

In depth

One network, hundreds of cities

Cloudflare sits in front of a large part of the web: in 2020 it said more than 26 million Internet properties depended on its configuration system. Its network spans data centres in 330 cities (2025), and every request a visitor makes to a Cloudflare-protected site passes through it. Cloudflare's engineering blog has described the layers of that path in detail: the server architecture (2019), the Unimog load balancer (2020), the Pingora proxy (2022), and Quicksilver, the system that gets configuration to every server (2020 and 2025).

Two principles run through all of it: anycast and uniformity.

Anycast

Cloudflare announces the same IP addresses from every data centre. The internet's routing then delivers each visitor's packets to one of them, usually a nearby one. That makes the whole network a single front door: there's no central entry point to overload, and an attack aimed at one address is spread across hundreds of locations. If a data centre becomes unreachable, routing carries its traffic to another.

Inside a data centre, routers spread each IP address across many machines (at least 16, in 2019) using ECMP.

Uniformity: every server runs everything

The second principle is that every server runs every service. Any machine can handle a connection for any service on any anycast address. Even the load balancer runs on the same general-purpose servers; the same software stack runs everywhere. Cloudflare's 2019 post describes the layers a packet passes through on a server:

  1. Volumetric DoS mitigation in XDP, an eBPF hook that runs before the kernel's network stack, dropping packets from very large attacks as early and cheaply as possible.
  2. Layer-4 load balancing, also in XDP: Unimog.
  3. The Linux network stack and iptables.
  4. The application layer: terminating TLS and handling HTTP, HTTP/2 and QUIC.

Unimog: load balancing without breaking connections

ECMP decides which server a packet first reaches, but Cloudflare needs control over where each connection is handled: to balance load and to take servers out of service. Unimog, its layer-4 load balancer, runs on the same general-purpose servers as everything else and costs less than 1% of their CPU. See load balancer.

It works with a forwarding table: each connection hashes to one of many buckets, more than 100 times the number of servers, and each bucket names the server that should handle it. Changing the table would normally break connections that hash to a reassigned bucket. Unimog avoids that with daisy chaining: each bucket also remembers its previous server. New connections go to the new owner; packets for existing connections that the new owner doesn't recognise are forwarded to the previous one. Fewer than 1% of packets take that second hop. Servers can be drained and replaced without dropping connections.

Pingora: the proxy

At the application layer, Cloudflare's HTTP proxy was NGINX until Cloudflare outgrew it. Its 2022 post introduces Pingora, a proxy written in Rust, which by then served over a trillion requests a day.

The biggest single problem with NGINX was connection reuse: its connection pool is per worker process, so a request on one worker couldn't reuse an open connection to an origin held by another. Pingora's multithreaded design shares connections. Across all customers it makes only a third as many new connections per second; for one major customer, connection reuse rose from 87.1% to 99.92%, cutting new connections to their origins 160-fold. Cloudflare estimated this saves 434 years of handshake time every day. Overall, Pingora used about 70% less CPU and 67% less memory than the old service for the same traffic, and reduced median time-to-first-byte by 5 ms.

Quicksilver: configuration everywhere, in seconds

Every request needs the site's configuration. It must be available on every server, readable in microseconds, and updatable worldwide in seconds. In 2015, after an earlier datastore, Kyoto Tycoon, began to struggle, Cloudflare wrote Quicksilver, a replicated key-value store built on LMDB. By 2020 it served 2.5 trillion reads and 30 million writes a day, and changes reached every city within seconds, with updates batched in 500 ms windows.

Originally every server held a full copy. By 2025 Quicksilver contained more than five billion key-value pairs (1.6 TB) and served over three billion keys per second, answering 90% of requests in under a millisecond, and copying everything to every server was wasting disk that caching needed. Quicksilver v2 keeps the full dataset only on a few replica servers per data centre. Every other server is a proxy with a local cache plus one shard of a data-centre-wide cache (1024 logical shards). A lookup checks the local cache, then the sharded cache, then a replica. With reactive prefetching, cache hit rates exceed 99.99%.

Most lookups are for keys that don't exist, about ten times more than for keys that do. A Bloom filter in memory answers 99% of those negative lookups without touching disk.

The trade-offs

Anycast gives automatic proximity and attack dilution, but traffic placement is decided by internet routing rather than per request. Uniform servers remove special-purpose bottlenecks while every service shares the same CPUs. Rewriting the proxy in Rust delivered large efficiency gains at the risk of replacing the most critical component. And caching configuration instead of copying it everywhere freed disk at the cost of occasional slower misses.

Compare with Netflix's content delivery, and see CDN and consistent hashing.

What to take into an interview

  • Use anycast so users reach a nearby site and attacks spread out
  • Run the same stack on every server to avoid special-purpose bottlenecks
  • Drop attack traffic as early as possible (XDP, before the kernel stack)
  • Load-balance with a large hashed table, and keep the previous owner so connections survive changes
  • Pool and reuse upstream connections across threads
  • Distribute configuration through a replicated store; cache it and use Bloom filters for misses

Components

Visitor

Client. A browser or app requesting a site that uses Cloudflare.

Anycast Router

BGP + ECMP

Load balancer. Every data centre announces the same IP addresses, so the internet delivers each packet to a nearby one. Routers spread each IP across many machines (at least 16 in 2019) with ECMP.

Why: Anycast turns the whole network into one big front door: traffic, including attacks, is spread across hundreds of locations.

Other Data Centres

CDN. Data centres in hundreds of cities serving the same IP addresses; if one is unreachable, traffic flows to another.

Building block: CDN

DoS Mitigation

XDP (L4Drop)

Service. The first software layer on each server: drops packets belonging to very large layer-3 attacks using eBPF in XDP, before the kernel's network stack.

Unimog

XDP L4 load balancer

Load balancer. Cloudflare's layer-4 load balancer, running on the same general-purpose servers as everything else. A forwarding table, over 100 times larger than the number of servers, maps each connection to a server; 'daisy chaining' keeps existing connections alive when servers change.

Building block: Load Balancer, Consistent Hashing

Pingora Proxy

Rust

API gateway. Cloudflare's HTTP proxy, built in Rust to replace NGINX. It terminates TLS and HTTP and forwards requests to origins, sharing connections across threads; it handles over a trillion requests a day.

Customer Origin

External API. The customer's own server, reached through pooled, reused connections.

Quicksilver

NoSQL database. Cloudflare's replicated key-value store for configuration, read on every request. Written in 2015 to replace Kyoto Tycoon; changes reach every city within seconds. Version 2 keeps full copies only on some servers and caches the rest.

Why: Every server needs every customer's configuration with microsecond reads, and changes must apply everywhere fast.

Building block: Replication, Bloom Filter, Cache

Root Nodes

NoSQL database. Dozens of servers in core data centres with terabytes of storage, holding the full dataset.

Intermediate Nodes

NoSQL database. Receive updates from upstream and pass them to leaf nodes within a data centre.

Replicas

NoSQL database. A few servers per data centre that store the full dataset.

Proxies (Sharded Cache)

Cache. Every other server keeps a local cache plus one shard of a data-centre-wide cache (1024 logical shards). Misses go local → sharded cache → replicas.

Bloom Filters

Cache. Answer 99% of negative lookups (ten times more common than positive ones) in memory without touching disk.

Building block: Bloom Filter

Configuration API

inferred

API gateway. Where customers change settings; writes enter Quicksilver at the root and are batched (500 ms windows in 2020) for distribution. The API itself isn't described in these posts.

Request flows

Serve a request at the edge

  1. A visitor's packets go to the anycast IP; BGP delivers them to a nearby Cloudflare data centre.
  2. The router spreads them across many servers with ECMP; XDP drops any packets from known attacks.
  3. Unimog looks up the connection in its forwarding table.
  4. The connection is forwarded to the server that owns it, where Pingora terminates TLS and HTTP.
  5. Pingora reads the site's configuration from Quicksilver, usually in under a millisecond.
  6. It forwards the request to the origin over a pooled, already-open connection.
  7. The response goes back to the visitor.

Change a setting worldwide

  1. A customer changes a firewall rule; the write enters Quicksilver at a root node.
  2. Within seconds the change has replicated to every data centre, and the next request sees it.

Failure scenarios

What if: a data centre goes offline?

Because every data centre announces the same addresses, the internet's routing sends traffic to another Cloudflare location when one stops announcing or becomes unreachable.

User impact: Slightly higher latency for nearby users.

  • Anycast across hundreds of cities
  • Every location runs every service

What if: a server is removed from a data centre?

Removing a server must not break its connections. Unimog keeps the previous owner in a second slot of each forwarding-table bucket and forwards packets for existing connections there, while new connections go to the new owner; under 1% of packets take the second hop.

User impact: None: connections survive.

  • Daisy-chained forwarding table
  • Drain servers instead of cutting them off

What if: a massive DDoS attack?

Anycast spreads the attack across many data centres, and XDP drops attack packets on each server before they reach the kernel stack, the load balancer or the proxy.

User impact: Ideally none.

  • Anycast dilution
  • XDP packet filtering
  • Every server shares the load

Trade-offs

Anycast everywhere

Announce the same IP addresses from every data centre.

Pros
  • Users reach a nearby site automatically
  • Attacks and failures spread across the network
Cons
  • Routing is decided by BGP, not by Cloudflare per request

Uniform servers

Run every service, including the load balancer, on every server.

Pros
  • No special-purpose bottlenecks
  • Capacity scales by adding identical machines
Cons
  • Every service shares CPU with every other

Rewrite the proxy in Rust

Replace NGINX with Pingora.

Pros
  • Connections shared across threads: far fewer new connections to origins
  • About 70% less CPU and 67% less memory for the same traffic
Cons
  • A large rewrite of the most critical component

Cache configuration instead of copying it everywhere

Quicksilver v2 keeps full copies on a few servers per data centre and caches the rest.

Pros
  • Frees disk on most servers
  • Cache hit rates above 99.99%
Cons
  • A cache miss is slower than a local full copy

Frequently asked questions

What is anycast?

Anycast means the same IP addresses are announced from many locations, and internet routing delivers each packet to one of them, usually a nearby one. Cloudflare announces the same addresses from every data centre, so users reach a close site and attacks are spread across the network.

What is Pingora?

Pingora is the HTTP proxy Cloudflare built in Rust to replace NGINX. It serves over a trillion requests a day using about a third of the CPU and memory of the old proxy, largely because it shares connections across threads, making only a third as many new connections.

How does Cloudflare distribute configuration?

Through Quicksilver, a replicated key-value store built in 2015. Changes are written at root nodes in core data centres and replicate through intermediate nodes to every location within seconds. In 2025 it held over five billion keys and served over three billion reads per second.

How does Unimog load-balance without breaking connections?

Unimog hashes each connection to a bucket in a forwarding table that is much larger than the number of servers. Each bucket keeps both its current server and the previous one, so packets for existing connections can be forwarded to the old server when assignments change.

Building blocks used

Sources