Okay, let's move on to 2.3 Networking. We covered some basics in Phase 1, but now we'll revisit and expand on key networking concepts crucial for understanding how distributed systems communicate.

We'll cover:

  • 2.3.a DNS (Domain Name System) (Deep Dive)
  • 2.3.b TCP/IP Model (Brief Review)
  • 2.3.c HTTP/HTTPS (Protocols & Methods)
  • 2.3.d RESTful APIs
  • 2.3.e WebSockets

Let's start with a deeper look at 2.3.a DNS (Domain Name System).

  • Recap: DNS is the phonebook of the Internet. It translates human-readable domain names (like www.google.com) into machine-readable IP addresses (like 172.217.160.142). Without DNS, we'd have to remember IP addresses to access websites.

  • Hierarchical and Distributed Nature: DNS is not a single server but a massive, globally distributed, hierarchical database. Key components include:

    • Root Servers: There are 13 logical root server clusters worldwide. They don't hold the info for every domain but direct queries to the appropriate TLD servers.
    • TLD (Top-Level Domain) Servers: Manage the last part of a domain name (e.g., .com, .org, .net, .uk, .in). They direct queries to the authoritative name servers for that specific domain.
    • Authoritative Name Servers: Hold the actual DNS records (IP addresses, etc.) for specific domains. They are the ultimate source of truth for a domain's DNS information. Usually managed by the domain registrar or hosting provider.
  • The DNS Lookup Process (Simplified): When you type a domain name:

    1. Client Check: Your browser/OS checks its local DNS cache. If found, the process stops here.
    2. Recursive Resolver: If not cached locally, the request goes to a Recursive Resolver (often provided by your ISP, or public ones like Google's 8.8.8.8 or Cloudflare's 1.1.1.1).
    3. Resolver Query: The resolver queries the Root Servers.
    4. Root Response: Root servers respond with the address of the relevant TLD server.
    5. Resolver Query: The resolver queries the TLD server.
    6. TLD Response: TLD server responds with the address of the Authoritative Name Server for that domain.
    7. Resolver Query: The resolver queries the Authoritative Name Server.
    8. Authoritative Response: The Authoritative Name Server responds with the IP address (or other requested record).
    9. Resolver Response: The resolver caches the result (respecting the TTL) and returns the IP address to your client.
    10. Client Connection: Your browser connects to the web server using the obtained IP address.
  • DNS Caching: Caching occurs at multiple levels (browser, OS, recursive resolver) to speed up lookups and reduce load on the DNS infrastructure. Each DNS record has a TTL (Time-To-Live) value that specifies how long it can be cached.

  • Common DNS Record Types:

    • A Record: Maps a domain name to an IPv4 address.
    • AAAA Record: Maps a domain name to an IPv6 address.
    • CNAME Record (Canonical Name): Maps a domain name to another domain name (an alias).
    • MX Record (Mail Exchanger): Specifies the mail servers responsible for receiving email for a domain.
    • NS Record (Name Server): Specifies the authoritative name servers for a domain.
  • DNS for Load Balancing:

    • Round Robin DNS: You can configure multiple A/AAAA records with the same domain name but different IP addresses. DNS servers often rotate the order in which they return these IPs.
    • Pros: Simple, no extra hardware needed.
    • Cons: Doesn't account for server health or load. DNS caching (client-side or resolver-side) can interfere, causing clients to stick to one IP even if it's overloaded or down. Not a very sophisticated load balancing technique compared to dedicated load balancers.
  • In an Interview: Understand the basic hierarchical lookup process, the importance of caching and TTL, and the common record types (especially A, CNAME). Be aware of Round Robin DNS as a basic load balancing mechanism and its limitations.

Advertisement