Day6 in System Designing
basic · System Designing
In the client-server model, for a client to make a request, it needs to know exactly where the server lives. This routing is handled by IP Addresses , while the discovery process is managed by the Domain Name System (DNS) . 1. IP Addresses: Machine Identification An IP (Internet Protocol) Address is a unique numerical label assigned to every device connected to a computer network. Think of it as a physical mailing address for a computer. There are two primary versions of IP addresses in use today: IPv4 (Internet Protocol Version 4): Written as four sets of numbers separated by periods (e.g., 192.168.1.1 or 172.217.16.14 ). It uses a 32-bit address space, allowing for roughly 4.3 billion unique addresses. Because the world has run out of unallocated IPv4 addresses, we use IPv6. IPv6 (Internet Protocol Version 6): Written in hexadecimal and separated by colons (e.g., 2001:db8:3333:4444:5555:6666:7777:8888 ). It uses a 128-bit address space, providing an astronomically large number of addresses (
.4 \times 10^{38}$ ). 2. DNS: The Phonebook of the Web Computers communicate using IP addresses, but humans remember words. The Domain Name System (DNS) resolves human-readable domain names (like google.com ) into machine-readable IP addresses (like 142.250.190.46 ). 3. The DNS Lookup Hierarchy When you type a URL into your browser, the resolution process happens through a series of specialized servers organized in a strict hierarchy. If a server doesn't know the answer, it refers the request down the chain. The Browser/OS Cache: Before making a network call, the client checks its internal history to see if it already knows the IP. DNS Recursor (Recursive Resolver): Usually operated by your Internet Service Provider (ISP) or third parties like Cloudflare ( 1.1.1.1 ) or Google ( 8.8.8.8 ). It acts as a middleman, querying other servers on your behalf. Root Nameserver: The first stop for the recursor. Root servers don't know the IP, but they know who manages the extensions. It points the recursor to the correct TLD server based on the suffix (e.g., .com , .org ). TLD (Top-Level Domain) Nameserver: Manages specific domain extensions. A .com TLD server won't know your exact site IP, but it knows the location of the specific server where your domain registry records are held. Authoritative Nameserver: The final destination. This server holds the actual mapping data (DNS records) configured by your domain registrar or hosting provider (Route53, Namecheap, GoDaddy). It returns the exact IP address back to the Recursor, which hands it to your browser. 4. Core DNS Record Types Inside the Authoritative Nameserver, data is stored in records. The most common types include: Record Type Purpose Example Value A Record Maps a domain directly to an IPv4 address. example.com $\rightarrow$ 192.0.2.1 AAAA Record Maps a domain directly to an IPv6 address. example.com $\rightarrow$ 2001:db8::1 CNAME Aliases one domain to another domain (not an IP). www.example.com $\rightarrow$ example.com MX Record Specifies the mail servers responsible for receiving email. mail.example.com TXT Record Holds arbitrary text (often used for domain ownership verification like SSL or Google Workspace). v=spf1 include:... 5. TTL (Time-To-Live) Because walking through the entire DNS hierarchy for every single web asset would cause massive latency, DNS results are heavily cached. TTL (Time-To-Live) is a setting inside each DNS record that dictates exactly how many seconds a local resolver, ISP, or browser is allowed to cache that record before it must query the authoritative nameserver again for a fresh copy. Low TTL (e.g., 60 to 300 seconds): Great when you are migrating servers or changing IPs. If something goes wrong, the changes propagate worldwide within minutes. Downside: Increases load on your nameservers and slightly slows down initial user requests because caching is brief. High TTL (e.g., 86400 seconds / 24 hours): Great for stable systems that rarely change. It decreases lookup latencies for users because records stay cached nearby. Downside: If your server crashes and you need to switch to a backup IP, users will hit the dead server until the 24-hour cache expires.