SkillPilotAI

DNS and GeoDNS

DNS converts a domain name (amazon.in) into an IP address, and GeoDNS gives the user the IP of the data center nearest to them.

1.1 Why is it used?

  • Users cannot remember IPs, so a name like flipkart.com is needed. DNS turns that name into an IP.
  • With GeoDNS / latency routing, a Mumbai user goes to the Mumbai region and a US user goes to the US region, which reduces latency.
  • DNS failover works together with health checks: when one region goes down, DNS starts returning the IP of another region.
  • With weighted records you can test a new version on 10% of the traffic (canary / blue-green migration).
  • DNS is the first step of every request. If DNS is down the whole website is down, so managed, anycast DNS is used.

1.2 How it works

DNS resolution flow
  1. 1.The user types shop.example.com in the browser
  2. 2.Browser cache -> OS cache (on a hit there is no query, until the TTL expires)
  3. 3.Recursive Resolver of the ISP / 8.8.8.8
  4. 4.Root server -> .com TLD server -> Authoritative DNS (Route 53 / Cloudflare)
  5. 5.IP + TTL come back, the resolver caches them, and the browser gets the IP

Every answer is cached until its TTL expires, so the full chain does not run every time

  • Resolution flow: Browser cache -> OS cache -> ISP Recursive Resolver -> Root server -> .com TLD server -> Authoritative server -> you get the IP.
  • Record types: A (IPv4), AAAA (IPv6), CNAME (points one name to another name), MX (mail), TXT (verification), NS (which server is authoritative).
  • TTL: how long a record stays cached. Low TTL (60s) = fast failover but more DNS queries; high TTL (1 day) = less load but slow changes.
  • Anycast: the same IP is announced from many locations around the world, and BGP takes the user to the nearest DNS server.
  • Routing policies: Simple, Weighted (70/30 split), Latency-based, Geolocation (country wise), Failover (primary/secondary), Geoproximity.
  • Health checks: the DNS provider pings the endpoint every 10-30 seconds, and if it is unhealthy its IP is removed from the answer.
  • Alias / CNAME flattening: the root domain (example.com) can also be pointed at a load balancer or CDN hostname.
  • DNSSEC: digitally signs the DNS response so that DNS spoofing / cache poisoning cannot happen.
GeoDNS / latency routing + health-check failover
  1. 1.Delhi user -> Route 53 (latency based policy, TTL 60s) -> Mumbai ALB IP -> App servers (ap-south-1)
  2. 2.New York user -> Route 53 -> Virginia ALB IP -> App servers (us-east-1)
  3. 3.A /health check runs every 30s on both regions
  4. 4.Mumbai down -> health check fails -> Route 53 gives the Delhi user the Virginia IP too
  5. 5.Users still see the site working, only latency increases a bit; traffic shifts within the 60s TTL

Short TTL = fast failover but more DNS queries; long TTL = fewer queries but slow changes

1.3 Which tools can be used

ToolTypeHow it is used
AWS Route 53Managed DNS (AWS)Latency, geolocation, weighted and failover routing + health checks. Alias record for ALB/CloudFront, 100% uptime SLA.
Cloudflare DNSManaged anycast DNSVery fast anycast network, with a free plan too. Turn on the proxy (orange cloud) and you also get CDN and DDoS protection along with DNS.
Azure DNS / Traffic ManagerManaged DNS (Azure)Azure DNS hosts the zone; Traffic Manager provides DNS-level routing (performance, geographic, priority, weighted).
NS1 (IBM)Managed DNS, advanced traffic steeringReal-time traffic steering with filter chains, popular for multi-CDN setups.
Google Cloud DNSManaged DNS (GCP)GCP's authoritative DNS; supports anycast and routing policies (geo, weighted round robin).
BIND / CoreDNSOpen-source DNS serverSelf-hosted DNS. CoreDNS is the default DNS inside Kubernetes for service discovery.

1.4 Comparison: Route 53 vs Cloudflare DNS vs Azure DNS vs NS1

PointRoute 53Cloudflare DNSAzure DNS (+ Traffic Manager)NS1
SpeedFast, global anycastGenerally the fastest in public benchmarksFast, global anycastFast, global anycast
Geo / latency routingYes: latency, geo, geoproximityThrough the Load Balancing add-on (paid)Through Traffic Manager (performance, geographic)Yes, very advanced filter chains
Health check + failoverBuilt-in health checksIn the Load Balancing add-onTraffic Manager endpoint monitoringBuilt-in monitoring + data feeds
Extra featuresAlias record for AWS resourcesCDN, WAF, DDoS togetherTight integration with Azure resourcesMulti-CDN steering, RUM data
CostPer hosted zone + per million queriesBasic DNS is freePer zone + per query, Traffic Manager billed separatelyEnterprise pricing, expensive
Best forApps running on AWSWorks with any cloud, when you want a security bundleApps running on AzureVery large, multi-CDN enterprises

1.5 When to choose which

  • Route 53: when the app is on AWS and you want latency + failover routing together with ALB/CloudFront.
  • Cloudflare DNS: when you want cheap/free, fast DNS and also want CDN + DDoS protection with it.
  • Azure DNS + Traffic Manager / Front Door: when the workload is on Azure.
  • NS1: when you need multi-CDN or very complex traffic steering (large media/streaming companies).
  • For a critical domain, always think of keeping 2 DNS providers (secondary DNS) to survive a single-provider outage.

1.6 Real-world example

Scenario: Global e-commerce site with Mumbai + Virginia regions

  1. The company has two regions: AWS ap-south-1 (Mumbai) and us-east-1 (Virginia), each with an ALB in front.
  2. In Route 53 a latency-based record is created for shop.example.com: Alias records to both ALBs, TTL 60 seconds.
  3. A Delhi user types shop.example.com in the browser, and the ISP resolver asks Route 53.
  4. Route 53 sees that latency from Delhi to the Mumbai region is lower, so it returns the Mumbai ALB IP.
  5. A health check hits /health on the Mumbai ALB every 30 seconds.
  6. An outage hits the Mumbai region, 3 health checks fail -> Route 53 marks the Mumbai record unhealthy.
  7. Now even Indian users get the Virginia IP; with a 60s TTL traffic shifts in about 1-2 minutes.
  8. Latency goes up a little but the site does not go down. That is the benefit of DNS failover.

1.7 Interview tips

  • The first step of 'What happens after you type a URL in the browser?' is DNS resolution. You should be able to say the whole chain (cache -> resolver -> root -> TLD -> authoritative).
  • Mistake: keeping the TTL very high (1 day). Then during a failover or IP change users keep going to the old IP for hours. Lower the TTL before a migration.
  • Mistake: trying to put a CNAME on the root domain. It is not allowed; use Alias/ANAME/CNAME flattening.
  • Mistake: treating DNS as a load balancer. DNS only returns an IP, it does not balance traffic at the connection level, and clients cache the answer.
  • A number to remember: TTL 60s + health check 30s x 3 failures = failover in about 1-2 minutes; TTL 1 day = old IP for hours.