Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 36 ยท Getting Started

The Cloudflare Network: Edge Locations and Anycast

Understand how Cloudflare's global network routes visitors to the nearest data center with anycast and BGP, what an edge is, and what happens inside one.

When you type a website address, your browser has to find a machine to talk to. Cloudflare's trick is that the machine it finds is almost always close to you, whichever country you are in. This lesson explains how that works, so later topics like caching, latency and DDoS protection make sense.

Data centers, edges and points of presence

Cloudflare operates servers in more than three hundred cities, connected to local internet exchanges and large network providers. Each location is called a data center, an edge location or a PoP (point of presence). The three-letter codes you will see in headers and logs are mostly airport codes: FRA (Frankfurt), SIN (Singapore), GRU (Sao Paulo).

Every edge server runs the full software stack. A request that arrives in Lagos is handled by the same kind of machine as a request in Tokyo: it terminates TLS, applies firewall rules, checks the cache and runs Workers code. There is no special "caching server" or "security server" you must route to. This uniformity is what makes the network simple to scale and hard to knock over.

Unicast versus anycast

Normally an IP address belongs to one machine in one place. That is unicast. If your website lives at 203.0.113.10, every visitor on Earth travels to wherever that machine is.

With anycast, the same IP address is announced from many places at once. The routers of the internet use the Border Gateway Protocol (BGP) to decide which announcement is shortest for each sender, and traffic follows that path. Two people on opposite continents can connect to the exact same IP address and reach two different Cloudflare data centers.

flowchart TB
  A["Visitor in Madrid"] -->|"104.16.x.x"| M["Cloudflare MAD"]
  B["Visitor in Seoul"] -->|"104.16.x.x"| S["Cloudflare ICN"]
  C["Visitor in Chicago"] -->|"104.16.x.x"| H["Cloudflare ORD"]
  M --> O["Origin"]
  S --> O
  H --> O

One address, many destinations: BGP picks the nearest route for each sender.

"Nearest" means fewest network hops or best routing policy, not always strict geography, but in practice it is very close to the visitor. Anycast also gives a natural defense: a flood of attack traffic is spread across the whole network because each attacking machine goes to its own nearest data center, instead of all converging on one server.

JS Stand-in: nearest data center by distance

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Notice that New York maps to Chicago here because we only listed five edges. Add { code: "EWR", lat: 40.69, lon: -74.17 } and watch the answer change. More locations mean shorter distances, and shorter distances mean lower latency.

Why distance matters

Light in fiber travels at roughly two thirds of the speed of light, so about 200 km per millisecond. A round trip between Sydney and Frankfurt is around 16,000 km each way, which means at least 160 ms of pure physics before any server does any work. A TLS handshake and an HTTP request need several round trips, so far-away servers feel slow no matter how fast they are.

JS Stand-in: round trips and distance

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Serving from a nearby edge turns the Sydney-to-Frankfurt problem into a Sydney-to-Sydney one. Only requests that must reach your origin still pay the long trip, and Cloudflare keeps connections to the origin open and reuses them so even those avoid repeated handshakes.

What happens inside an edge server

When a request reaches a data center, roughly this pipeline runs:

  1. The network layer filters obvious attack traffic (DDoS mitigation happens before your site's rules).
  2. TLS is terminated, so the connection to the browser is encrypted using a certificate Cloudflare holds for your hostname.
  3. HTTP is parsed; the protocol can be HTTP/1.1, HTTP/2 or HTTP/3 independent of what your origin speaks.
  4. Rules run: WAF, rate limiting, redirects, transforms, cache rules and so on.
  5. The cache is checked. On a hit the response is returned; on a miss the edge fetches from the origin, then may store the response.
  6. Workers, if attached, can run at several points and alter the request or response.

Later chapters take each step apart. For now the important point is that all of it happens at the edge near the visitor, before your origin is involved.

Seeing the edge in a real response

Any site behind Cloudflare returns diagnostic headers. You can inspect them with a command-line tool:

Terminal
curl -sI https://example.com | grep -i -E "^(server|cf-ray|cf-cache-status)"

Typical lines look like server: cloudflare, cf-ray: 8a1b2c3d4e5f6789-FRA (the suffix is the data center code of the edge that served you) and cf-cache-status: HIT or MISS. The cf-ray ID is unique per request; support teams ask for it, and you can write it into your own logs to trace a problem.

You can also visit https://yourdomain.com/cdn-cgi/trace on a proxied hostname. It prints plain text such as the colo code, your IP, and whether HTTP/3 was used.

Tiers of network

Some Cloudflare features use the network differently:

  • Cloudflare CDN and proxy use the anycast edge described above.
  • Argo Smart Routing (paid) steers origin-bound traffic over faster, less congested paths between Cloudflare data centers.
  • Cloudflare Tunnel lets an origin connect outbound to the network, so it needs no public IP at all (covered in the Zero Trust chapter).
  • Magic Transit protects a company's own IP ranges by announcing them through Cloudflare's anycast network.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What makes an address anycast?

    Anycast announces one IP from many places; BGP delivers each sender's packets to a nearby announcer.
  2. 2. Which protocol do internet routers use to choose paths between networks?

    The Border Gateway Protocol exchanges routes between autonomous systems and underpins anycast.
  3. 3. What does the suffix of a cf-ray header (like -FRA) tell you?

    The three-letter code is the Cloudflare data center, usually named after a nearby airport.
  4. 4. Why does anycast help against DDoS attacks?

    Each attacking machine reaches its own nearest edge, so no single location absorbs the whole flood.

Summary

  • Cloudflare runs identical software in hundreds of cities; each is an edge, data center or PoP.
  • Anycast announces one IP from many places; BGP sends each visitor to a nearby one.
  • Distance costs latency; the edge removes most long trips and spreads attack traffic.
  • cf-ray, cf-cache-status and /cdn-cgi/trace reveal which edge served you.

Next: Account, plans and the API