- PM Tech House đ
- Posts
- Part 3: System Design 101 (DNS & CDN, the Dynamic Duo đ)
Part 3: System Design 101 (DNS & CDN, the Dynamic Duo đ)
Behind the Scenes of DNS & CDN
Welcome to another edition of System Design 101 at PMTechHouse, where we break down complex tech concepts into bite-sized, easily digestible pieces. Apologies for the delay this week. Today, we're diving into the world of DNS and CDNâtwo unsung heroes that make your internet experience smooth and speedy.
DNS: Domain Name Server
Imagine trying to find your friend's new house without an addressâjust a name. Frustrating, right? That's the internet without DNS. DNS is like the internet's GPS, translating human-friendly domain names (like www.pmtechhouse.com) into machine-friendly IP addresses (like 192.168.1.1).
Here's how it works:
You type "pmtechhouse.com" in your browser.
Your device asks a DNS server, "Where's pmtechhouse.com?"
The DNS server replies, "It's at 192.168.1.1!"
Your browser goes to that address.
DNS Architecture:
Hierarchy: DNS is organized in a top-down structure, with a few powerful servers at the top.
Lookup Process: When you search for a website, your internet service provider (ISP) or router directs the request to a DNS server.
Caching: To speed things up, lower-level DNS servers store (cache) results. Your browser and operating system also cache DNS results for a period defined by the time to live (TTL).
There are a couple of records you should keep in mind
Key DNS Records:
NS Record (Name Server): Tells which DNS servers are in charge of your domain.
MX Record (Mail Exchange): Points to the mail servers that handle email for your domain.
TXT Record: Stores text information, often used for SPF, DKIM, and DMARC for email security.
A Record (Address): Directly maps a domain name to an IP address.
AAAA Record: Similar to A Record, but for IPv6 addresses.
CNAME (Canonical Name): Redirects one domain name to another (like pmtechhouse.com to www.pmtechhouse.com).
Managed DNS Services:
Companies like Cloudflare, AWS Route 53, and Google Cloud DNS offer services to manage DNS efficiently. These services provide advanced features to enhance performance and reliability:
Weighted Round Robin: Distributes traffic evenly across servers.
Failover: Redirects traffic when a server is down.
Geo-DNS: Routes users to the nearest server based on location.
Load Balancing: Adjusts traffic based on server capacity.
A/B Testing: Directs users to different site versions for testing.
Latency-Based Routing: Sends users to the fastest responding server.
Health Checks: Monitors server health to avoid routing to faulty servers.
DNS might seem technical, but itâs crucial for ensuring that you reach the right websites quickly and reliably. Whether youâre browsing, sending emails, or managing a website, DNS works behind the scenes to keep everything running smoothly.
CDN: Content Delivery Network
Now, let's talk about CDNs (Content Delivery Networks). Imagine ordering a pizza from a single shop in New York, no matter where you are in the world. New Yorkers get hot pizzas, but yours might arrive cold in Tokyo! CDNs solve this by creating "pizza shops" (servers) worldwide. When you order your "pizza" (request content), it comes from the nearest shop.
A Content Delivery Network (CDN) is a globally distributed server network that delivers content (like images, videos, and HTML/CSS/JS files) from locations closer to users. This proximity speeds up content delivery and reduces the load on your servers. Hereâs how it works:
Improved Performance: Users receive content from nearby data centers.
Reduced Server Load: Your servers handle fewer requests since the CDN fulfills many of them.
Types of CDNs:
Push CDNs:
Operation: You upload new content directly to the CDN whenever it changes.
Best For: Sites with low traffic or infrequently updated content.
Advantages: Minimizes traffic; content is uploaded only when itâs new or changed.
Configuration: You control when content expires and is updated.
Pull CDNs:
Operation: The CDN grabs new content from your server when a user requests it.
Best For: Sites with high traffic and frequently updated content.
Advantages: Minimizes storage space on the CDN.
Configuration: Content is cached based on time-to-live (TTL) settings.
Considerations:
Cost: CDNs can be expensive, but they often save costs compared to not using a CDN.
Stale Content: Content may become outdated before TTL expires.
URL Changes: Static content URLs must point to the CDN.
By effectively using DNS and CDN, you can ensure faster, more reliable access to your website, enhance user experience and reduce server load. Whether youâre a tech enthusiast or just curious, understanding these systems can help you appreciate the Internet's complexity and efficiency.