How The Internet Works
Build a mental model of how the internet connects clients and servers through layered protocols and infrastructure
Big Picture: The Request Lifecycle
Request travels down.
User intent formed
- The Internet request lifecycle is a coordinated sequence of specialized layers working in order.
- Each layer solves a distinct systems problem and passes responsibility to the next.
- What feels like a single action is actually a structured pipeline executing across multiple abstractions.
Details
Browser → DNS → TCP → HTTP → Server → Database → Response → Render
At a high level, a web request is not a single action but a chain of systems working together. Each step exists to solve one specific problem - finding the destination, establishing communication, defining the request, processing logic, retrieving data, and returning results.
DNS answers “Where is this service located?” TCP answers “How do we reliably communicate?” HTTP answers “What exactly is being requested?” The server and database answer “What should the system compute and return?”
These layers operate independently but cooperate in sequence. No single component understands the whole system - each performs its role and passes control to the next.
What feels instant to a user is actually a structured pipeline of abstractions executing in milliseconds.
The Trigger: Typing a URL
Humans type names. Networks require numeric routing identities.
- A URL is a user-friendly label, not a direct network address.
- The browser extracts the domain and prepares it for resolution.
- The domain must be translated into an IP address before communication begins.
Details
When a user types a URL, the browser does more than just “open a page.” It first parses the input to identify the protocol (such as HTTPS), the domain name, and the requested path.
Computers cannot route traffic using domain names like example.com. Networks operate on IP addresses, which are numerical identifiers.
The browser checks its local cache to see whether it already knows the IP address for that domain. If not, it initiates a DNS lookup process to resolve the name into a routable IP address.
Only after this translation step can the system move forward to establishing a connection.
Name to IP: DNS Resolution
DNS converts human-readable domain names into IP addresses through a hierarchical and globally distributed lookup system.
Cache hit: instant. Cache miss: full DNS hierarchy traversal.
- DNS changes a website name into the numeric IP address that computers use to communicate.
- The lookup follows a step-by-step path across different DNS servers until the correct address is found.
Details
DNS is designed as a distributed directory for the Internet. Instead of relying on one central database, responsibility is divided across multiple layers of servers to support global scale.
When a domain is not already known locally, a recursive resolver begins the lookup process. It first contacts a root server, which points to the correct Top-Level Domain (TLD) server such as .com or .org. The TLD server then directs the resolver to the authoritative name server for that specific domain.
The authoritative server provides the final IP address. That address is returned to the client, allowing the browser to move forward and establish a network connection to the correct destination.
This layered design keeps DNS organized, scalable, and capable of supporting billions of lookups every day.
Connection: The TCP Handshake
Reliable communication only begins after both sides agree on how the conversation will work.
Client
Server
Client: Let's synchronize!
- TCP ensures data arrives reliably and in the correct order.
- Before sending data, both sides perform a three-step handshake.
- This handshake confirms readiness and synchronizes sequence numbers.
Details
TCP does not immediately start sending application data. It first establishes a connection using a three-step process: SYN → SYN-ACK → ACK.
The client begins by sending a SYN (synchronize) message to request a connection. The server responds with SYN-ACK, acknowledging the request and sharing its own starting sequence number. The client then sends an ACK to confirm receipt. At this point, both sides agree on initial sequence numbers and know the other side is ready.
This exchange sets up the foundation for reliable delivery. TCP tracks sequence numbers, detects lost packets, retransmits missing data, and adjusts sending speed based on network conditions.
Only after this coordination step does actual application data begin to flow.
Application Layer: HTTP
HTTP defines how clients request resources and how servers respond through a structured request-response protocol.
- HTTP defines a common language that both browsers and servers agree to follow.
- It standardizes how resources are requested and how responses are formatted.
- It turns raw network data into meaningful actions like “fetch this page” or “submit this form.”
Details
TCP ensures reliable delivery of bytes, but it does not define what those bytes mean. HTTP sits above TCP and gives structure and semantics to the communication. It defines how a client asks for something and how a server responds.
An HTTP request includes a method (such as GET or POST), headers that describe metadata, and optionally a body containing data. The server replies with a status code, headers, and the requested content. Because both sides follow the same rules, they can interpret messages consistently.
HTTP is essential because the Internet is a shared system. Without a common protocol defining message structure and intent, browsers and servers would not understand each other. HTTP creates that shared language for the web.
It defines what is being requested and returned, not how the data physically travels across the network.
Inside the Server
A server works because the operating system manages hardware resources while application code handles and responds to requests.
Incoming requests
OS assigns CPU + memory → app executes logic
Responses sent
- A client request arrives and is delivered to a server program through the operating system.
- The operating system allocates CPU time, memory, and network access to process that request.
- The server application executes logic and produces a response to send back.
Details
When data reaches a machine, it does not automatically “run.” The operating system receives network data and directs it to the correct process using sockets. This is how the request reaches the server program.
The OS then manages the necessary resources. It schedules CPU time so the server can execute, assigns memory for processing, and controls access to files or databases. Without the operating system coordinating these resources, multiple requests could not be handled safely or efficiently.
Once the request is inside the server process, the application logic takes over. It interprets the HTTP message, performs any required computations or database lookups, and constructs a response.
The operating system enables execution. The server application defines the behavior.
Database & Persistence
A database is a system designed to store, organize, and reliably retrieve application data over time.
| ID | Name | Role |
|---|---|---|
| 21 | Alice | User |
| 22 | Brian | Admin |
| 23 | Cathy | User |
| 24 | Daniel | User |
| 25 | Eva | Admin |
- Databases exist to store data durably beyond a single program’s execution.
- They organize information so it can be efficiently searched and updated.
Details
Applications constantly generate data — user accounts, posts, transactions, logs, and configurations. If this data lived only in memory, it would disappear whenever the program restarted. Databases solve this by providing durable storage on disk or distributed systems.
But storage alone is not enough. Data must be structured and queryable. Databases organize information into tables or collections and provide query languages that allow applications to retrieve specific records without scanning everything manually.
To improve performance, databases use indexes — specialized data structures that act like a lookup map. Instead of checking every row, the engine can jump directly to relevant entries.
Databases are critical because modern applications require persistent state. Without them, every request would operate in isolation with no memory of prior activity.
Performance Layers: Caching and CDN
Modern systems improve speed by storing frequently requested content closer to users instead of recomputing it every time.
- Caching avoids repeated computation by serving stored responses.
- CDNs distribute content geographically to reduce latency and origin load.
Details
When a user requests the same resource multiple times, recomputing it from scratch is inefficient. Caching solves this by storing a copy of the response so future requests can be served immediately without hitting the database or application logic again.
Caches exist at multiple layers — inside the browser, on the server, and at the network edge. A Content Delivery Network (CDN) extends this idea globally by distributing content to geographically dispersed data centers. Instead of always contacting the origin server, users are routed to the nearest edge location.
Reducing physical distance lowers network latency, and reducing repeated computation lowers server load. Together, these optimizations dramatically improve response time at scale.
However, cached data can become outdated, so systems must balance speed with data freshness.
Failure Points
In a layered system, any component along the path can fail, and the overall experience depends on how well the system handles those failures.
DNS
TCP
Server
Database
- Every layer in the request lifecycle can fail independently.
- Failures in one component can prevent the entire request from completing.
- Reliable systems anticipate and recover from partial failures.
Details
Because the Internet request lifecycle spans DNS, transport, servers, and databases, problems can occur at any stage. If DNS cannot resolve a domain, the connection never begins. If the network drops packets or the TCP connection breaks, communication is interrupted.
Even after a request reaches the server, failures can still occur. The server process might crash, run out of memory, or fail to connect to the database. A slow or unresponsive database can delay the entire response.
Distributed systems rarely fail all at once. Instead, they fail partially — one region, one instance, or one dependency at a time. Designing resilient systems requires adding redundancy, health checks, retries, and fallback mechanisms across multiple layers.
Understanding where failures can occur is essential to understanding how real-world systems behave.
Question Section
1 / 5