Course contentsShow
← System Design
Lesson 1616 of 1,91939. Real-World System: Image and Video HostingFree lesson

Geographic Routing and DNS

Using GeoDNS and Anycast to route users to the nearest CDN edge for minimal latency.

Geographic Routing and DNS

You'll learn how to route users to the nearest CDN edge server automatically using GeoDNS and Anycast for minimal latency.

The Problem

When your media hosting service has users worldwide, you need to route each user to the CDN edge server closest to them. Sending a user in Tokyo to a server in London wastes hundreds of milliseconds on network round-trips.

How Geographic Routing Works

GeoDNS is a DNS service that returns different IP addresses based on the requester's geographic location. When a user's browser queries cdn.yourservice.com, the DNS resolver checks the origin of the request and returns the IP of the nearest edge server.

Think of it like a smart phone book: when someone in California calls "Pizza Place," they get the local branch's number, while someone in New York gets a different branch automatically.

Anycast is a complementary technique where multiple servers share the same IP address. Network routing protocols automatically direct traffic to the topologically nearest server. If one server goes down, traffic seamlessly routes to the next closest one.

Why This Matters for Media

  • Latency reduction: Users connect to nearby servers (10-50ms instead of 200-300ms)
  • Load distribution: Traffic spreads across regions naturally
  • Failover: Dead servers are bypassed automatically
  • Bandwidth optimization: Regional peering agreements reduce transit costs

Integration with Previous Concepts

After your Origin Shield serves content to edge servers, GeoDNS ensures users discover the right edge. Combined with signed URLs (lesson 1615), you control both where and who can access your media efficiently.

Key Takeaway: GeoDNS and Anycast form the intelligent routing layer that connects users to their optimal CDN edge server, minimizing latency without requiring application-level logic.