November 2026
How the Web Works
You type a few letters into the bar at the top of a browser, press Enter, and a fraction of a second later a page appears. The page didn't come from your computer. It came from another machine, often thousands of kilometers away, that you've never seen and couldn't find on a map. Somehow your request found that machine, and its answer found its way back to you.
In this article we'll follow that trip from beginning to end. The demonstration below shows the whole thing at once. Your computer first asks a few machines what the name you typed stands for, then sends a small request across a chain of routers to the server, which sends the page back:
This may look like a lot of machinery for something that feels instant, and it probably raises more questions than it answers. What is a router? Why does a name need to be looked up? Who decided which machine answers for a name, and who pays for it? By the end of this article every piece of this picture will make sense, along with the words people throw around when they talk about websites: IP address, DNS, domain, registrar, host, VPS, HTTPS.
We'll start with the simplest possible network: two computers and one wire. Some demonstrations in this article are animated. You can pause or resume all of them at once, or use the button in the corner of each one.
Wires and Bits
Let's connect two computers with a cable. To send a message, the computer on the left changes the voltage on the wire, high or low, many times a second, and the computer on the right watches the voltage and writes down what it sees. A high voltage stands for a 1, a low voltage for a 0. You can drag the slider to move through time and watch the word "Hi" make its way across:
Each letter becomes a group of eight ones and zeros, following a code that both computers agree on. A single one or zero is called a bit, and a group of eight is a byte. Anything a computer can store can be sent this way, as long as both ends agree on what the bits mean: a letter, a color of a pixel, a piece of a song. As you can see halfway through, the bits travel one after another, so a long message takes longer to send than a short one.
Real cables are much faster than this drawing. An ordinary home network cable carries a billion bits each second, and the glass fibers that cross oceans carry many thousands of times more. Some links don't use a wire at all: Wi-Fi sends the same kind of pulses as radio waves, and fiber sends them as flashes of light. For the rest of this article the details of the link won't matter. All we need is that bits go in at one end and come out at the other.
Now, a link is rarely used by just one conversation. Below, two computers on the left want to send something to two computers on the right, and they share the one link in the middle. The first conversation has a long message to send, and the second one has a short one. The buttons switch between sending each message in one piece and cutting it into small pieces:
When each message travels whole, the short message has to wait until the long one is completely through. One large download would freeze every other conversation on the link. When the messages are cut into pieces, the pieces of the two conversations take turns, and the short message gets through almost at once.
Those small pieces are called packets, and the whole internet is built on them. A typical packet carries at most about 1,500 bytes, so a photo of a few megabytes travels as a few thousand packets. Each packet also carries a small header in front of its contents, a bit like the writing on an envelope. We'll soon see what that header has to say, because the moment more than two computers are involved, a packet needs to know where it's going.
Addresses
Let's connect six computers to one shared network. A packet put on the network reaches all of them, so we need a way to say which one it's meant for. The simplest solution is to give each computer a number, and to write the number of the destination on every packet. You can click any computer to send it a packet from the one on the left:
Notice that every computer sees the packet, but only the one whose number matches the address on the packet keeps it. The others simply ignore it. The packet also carries the address of the sender, so that the receiver knows where to send its answer.
On the internet, these numbers are called IP addresses, after the Internet Protocol, the set of rules that describes what a packet looks like. The original version of an IP address is 32 bits long. Thirty-two ones and zeros are hard to read for a person, so we split them into four groups of eight and write each group as an ordinary number. You can click any bit to flip it:
Eight bits can count from 0 to 255, so each of the four numbers falls in that range. If you set all bits to one, you get 255.255.255.255, and if you clear them all, you get 0.0.0.0. I've started the figure at 203.0.113.10, which is the address we'll give to our web server for the rest of the article. It comes from a block of addresses reserved for examples, so it doesn't belong to anyone.
Thirty-two bits allow about 4.3 billion different addresses. In the 1980s that seemed like more than anyone would ever need, but today there are more phones than that, and the organization that hands out blocks of addresses gave away its last free ones in 2011. A newer version, IPv6, uses 128 bits per address, which is enough to give every grain of sand on Earth a vast number of addresses of its own. IPv6 addresses are written in a different style, like 2001:db8::10, and today a large part of internet traffic already uses them. The ideas in this article work the same for both versions, so I'll stay with the shorter, friendlier IPv4 addresses.
Shouting every packet to every computer works for six machines in a room. It doesn't work for billions of machines around the world. We need something cleverer.
Routers
Instead of one giant shared network, the internet is a patchwork of many small networks, joined by machines called routers. A router is connected to a few neighbors, and its only job is to receive a packet, look at its destination address, and pass it on to the neighbor that is closer to that destination.
For this to work, addresses are handed out in blocks, a bit like postal codes. All the computers in one neighborhood of the network share the same start of their address. In the demonstration below, I've drawn a small internet of routers, and each colored patch is a network whose addresses all start with the number written on it. Your computer is on the left. You can click any patch to send a packet there:
Notice that no router knows the whole route. Each one only knows which of its neighbors to hand the packet to, given the first part of the address, and that is enough. The packet hops from router to router until it reaches the network where the address lives. Each router keeps a routing table: a list that says, for each block of addresses, which neighbor is the way to go.
This design has a wonderful property. Since every router makes its own decision for every packet, the network can route around damage. In the version below, you can click any link between two routers to cut it, and click it again to repair it:
When a link is cut, the routers at its two ends notice, tell their neighbors, and within moments every router has updated its table. The packets simply take another way. You can cut quite a lot of the network before the destination becomes unreachable. Routers keep each other informed with a protocol called BGP, and the main routers of the internet each know close to a million blocks of addresses.
The patches in this drawing are, roughly, what the internet is made of: the networks of internet providers, universities, companies, and the large data centers where websites live. Each of these networks connects to a few others, and the internet is nothing more than all of them agreeing to pass each other's packets on. One of those patches is very close to you. It's time to look at your own home.
Your Home
The box that your internet provider gave you is a router, too. On one side it connects to the devices in your home, over cable or Wi-Fi, and on the other side to the network of your provider. But there's a twist. Your provider gives your home just one public IP address, and there may be ten devices that want to use it.
The trick is that the devices in your home get private addresses, from blocks that are reserved for use inside homes and offices, such as 192.168.1.x. Millions of homes use the same private addresses at the same time, and that's fine, because these addresses never leave the home. In the demonstration below, a device in the home sends a packet to our server. Watch what the home router does to the packet's sender address as it passes. The buttons pick the device, and the slider moves through time:
As the packet leaves the home, the router replaces the private sender address with its own public one, and it adds a small number of its own to tell the conversations apart. It writes this swap down in a table. When the answer comes back, it's addressed to the router, which looks up the number in its table and passes the packet to the right device. If you pick the phone, you'll see that it gets a different number in the table. This rewriting is called network address translation, or NAT, and it's the main reason the world hasn't completely run out of IPv4 addresses.
A side effect is that devices in your home can make connections out, but nobody outside can start a connection in: the router wouldn't know which device to give it to. That's fine for a laptop that reads web pages. It's not fine for a computer that wants to serve web pages to others, and we'll come back to that when we talk about servers. Before that, there's something we've ignored so far: all those hops take time.
Distance
Between your router and a server on another continent, a packet travels mostly through optical fiber: thin threads of glass that carry bits as flashes of light. Light is fast, but light in glass is about a third slower than in empty space, and it covers about 200,000 km each second. That sounds instant, but over the distances of the world it adds up. The slider below sets the distance between you and the server:
Light in fiber needs about 5 milliseconds for each 1,000 km. A server in the same city answers in a blink, but from London to New York the light needs about 28 ms one way, and you have to wait for it to get there and back before you see any answer. The time for the trip there and back is called the round-trip time. From London to Sydney it's at least 170 ms, which is long enough to notice.
And these are the best possible times. Real cables don't follow the straight line, and each router on the way adds a little delay of its own, so real round trips are often one and a half times longer. No engineering can make light go faster, so the only ways to make a web page faster are to make fewer round trips, or to move the server closer. We'll see both tricks later on. But first, we need to deal with an uncomfortable fact: some packets never arrive at all.
Reliable Delivery
A router that receives more packets than it can send on simply throws some of them away. A bit of radio noise can damage a packet on Wi-Fi, and a damaged packet is thrown away, too. The IP rules make no promise that a packet arrives, or that packets arrive in the order they were sent.
The fix is to number the packets and to ask the receiver to confirm what it got. In the demonstration below, the sender on the left sends six numbered packets, and the receiver on the right answers each one with a short receipt. The buttons decide which packet gets lost on the way, and the slider moves through time:
When nothing is lost, every packet gets its receipt and the job is done. When packet 3 is lost, the receiver keeps the packets that came after it, but its receipts keep saying "I have everything up to 2". After a short wait, the sender sends packet 3 again, and the receiver can put the whole message back in order. These receipts are called acknowledgments.
This system of numbers, receipts, and second tries is called TCP, the Transmission Control Protocol. It runs on the two computers at the ends, and the routers in between know nothing about it. Together with IP, it's so central that people often call the whole thing TCP/IP.
For the numbering to work, both sides have to agree on where to start counting before any data flows. So a TCP conversation, called a connection, always opens with a short exchange of three messages. In the drawing below, time runs down the page, and each arrow is one message. I've made the arrows slant because each message needs time to cross the distance:
The client says "let's talk" (a message called SYN), the server answers "OK, let's talk" (SYN-ACK), and the client confirms (ACK) and can send its request with the confirmation. This is the three-way handshake. Notice that the client can't send its request until a full round trip has passed. A connection to a server across an ocean costs a sizable fraction of a second before anything useful happens.
There's one more number in each packet that we need. A server usually runs several programs that talk to the network: one for web pages, one for email, one for remote logins. The IP address brings a packet to the right computer, and a second number, the port, brings it to the right program on that computer. The buttons below pick the port that the packet is addressed to:
Each program on the server listens on its own port. By convention, web servers listen on port 80 for plain web pages and on port 443 for secure ones, remote logins use port 22, and mail servers talk to each other on port 25. So the full address of a web page's server is something like 203.0.113.10, port 443. That's precise, but nobody wants to type it. We need names.
Names
In the early days of the internet, the solution was a single file. One organization kept a list of every computer's name and address, and every computer downloaded a fresh copy of the list now and then. The slider below sets the number of computers on the network, and the plot on the right shows how much the downloads of the list add up to:
With a few dozen computers, the list is short and the downloads are trivial. But each new computer makes the list longer and adds one more computer that downloads it, so the total traffic grows with the square of the number of computers. With thousands of computers, the one server that holds the list is overwhelmed, the list changes faster than anyone can download it, and every new name has to wait for one office to approve it. By the early 1980s, that was exactly what was happening.
The solution, invented in 1983, was to split the list into pieces and give each piece to a different owner. Names became a tree. The demonstration below shows a small part of it. You can click any name at the bottom to see where it lives in the tree:
A full name is read from right to left, from the root of the tree down to the leaf. In www.example.com, "com" is a branch near the root, "example" is a branch under "com", and "www" is a leaf under "example". The last part, like com, org, or uk, is called the top-level domain. A domain is any branch of the tree together with everything below it, so example.com is a domain, and so is .com.
The power of the tree is that each branch is managed by a different owner. The people who run .com decide who gets names directly under .com, but they don't care what's under example.com: that's up to the owner of example.com, who can create www.example.com, shop.example.com, or anything else, without asking anyone. The same label can also appear in many places without any conflict, like the "www" in www.example.com and in www.example.co.uk. This system of names is the Domain Name System, or DNS.
Looking Up a Name
Each branch of the tree has a few computers that know about it, called its name servers. To find the address of a name, you start at the root and walk down. Your computer doesn't do this walk itself. It asks a helper called a resolver, usually run by your internet provider, though you can choose another one, such as 1.1.1.1 or 8.8.8.8. The slider moves through the steps of one lookup of www.example.com:
The resolver first asks a root server, which doesn't know the address, but knows which servers handle .com. The resolver then asks a .com server, which doesn't know the address either, but knows which servers handle example.com. Those servers finally give the answer: 203.0.113.10. The servers for example.com are called authoritative for that domain, because they're the ones that hold its records.
The root is the top of the whole system, so it may sound like a weak point. There are 13 root server names, run by 12 different organizations, and each name is served by many copies spread around the world: well over a thousand machines in total. A trick called anycast lets all copies of one root server share the same address, and the routers simply deliver a packet to the nearest one.
Three round trips for every name would make the web slow, and the root servers would drown in questions. So the resolver remembers every answer it gets. This memory is called a cache. Below, each mark on the timeline is a question that some user asks the resolver about one name, over 24 hours. A tall mark is a full lookup, and a short mark is an answer straight from the cache. The slider sets how long the resolver may keep an answer:
How long an answer may stay in a cache is set by the owner of the name, and it's called the time to live, or TTL. With a long TTL, nearly every question is answered from the cache. But I've also made the owner of the name move the website to a new server at the eighth hour. A gray mark with a cross is a user who got the old address from the cache. With a long TTL, users keep getting the old address for hours after the move. With a short TTL, the change reaches everyone quickly, but the resolver has to ask again and again.
That is why people say a DNS change "needs time to propagate". Nothing actually spreads: the old answers simply sit in caches around the world until their time to live runs out. Caching also happens in many places at once, in your browser, in your computer, and in the resolver, so most lookups never leave your machine. But this raises a question we've avoided: how does a name get into the tree in the first place, and who is the owner?
Who Owns a Name
At the top of the tree sits ICANN, a non-profit organization that decides which top-level domains exist. Each top-level domain is run by one organization, called its registry. The registry keeps the list of all names in its domain and runs its name servers. The registry for .com, for example, is a company called Verisign. But registries don't sell names to the public. That's the job of registrars: the shops where you buy a domain. The slider below follows the purchase of example.com:
You pay a registrar, which passes the request on to the registry. The registry adds one line to its list of .com names. Notice what that line says: not the address of your website, but the names of the servers that are authoritative for your domain. That's exactly the hint that a .com server gave the resolver in the lookup above.
So "buying" a domain really means renting the right to put one line in the registry's list, usually for a year at a time. If you forget to renew, the line is removed, and somebody else can rent the name. Most registrars also run name servers for their customers, so for most people the registrar is also where they edit the records of their domain.
Those records come in a few types. The buttons below pick a type of record of example.com:
An A record gives an IPv4 address, and an AAAA record gives an IPv6 address. A CNAME record says "this name is another name for that one", so the resolver has to look that other name up as well. An MX record says which server receives email for the domain. When a guide tells you to "point your domain to your server", it means: create an A record with the server's address.
We now know how a request finds the right address. It's time to look at what sits at that address.
Servers
A server is a computer that answers requests. There's nothing magic about it: you could run a web server on your laptop. But a server has to be switched on all the time, it needs a public IP address that nobody else uses, and it needs a fast and reliable connection. A home has none of these, so most servers live in data centers: large buildings full of computers, with backup power, cooling, and fat connections to many networks.
Servers in a data center don't look like laptops. They are flat boxes, stacked in tall cabinets called racks. You can drag the rack to look at it from another side, and the slider pulls one server out:
Inside, a server has the same parts as your laptop: processors, memory, storage, and a network connection. It just has more of them, and no screen or keyboard. One of these machines is often far more than one small website needs. So the owner of a data center usually splits each machine into several smaller, independent ones. The slider sets the number of slices:
A program called a hypervisor runs on the physical machine and gives each slice its own share of the processor cores and memory. Each slice behaves like a complete computer: it has its own operating system, its own files, and its own IP address, and it can't see the others. Such a slice is called a virtual machine, and when you rent one, it's called a virtual private server, or VPS. A VPS is the cheapest way to have a computer of your own on the internet, running day and night, with a public address.
Renting a VPS is one of several ways to put a website online, and all of them are called hosting. The company that rents you the space is a host, or a hosting provider. The options differ in how much of the work is yours. In the drawing below, each column is one kind of hosting, and each row is a layer of the work that a website needs. The layers that you manage are colored, and the ones the provider manages are gray:
With a server at home you do everything, including keeping the power on. With a VPS, the provider runs the building and the hardware, and you get an empty computer: you install the operating system updates, the web server program, and your files. With shared hosting, many customers share one machine that the provider maintains, and you only upload your files. With a static host, you upload finished pages and the provider does the rest, often on many machines at once. More control means more work, and the right choice depends on what the website needs to do.
Whichever we pick, a program on the server now listens on port 443, waiting for a request. Let's finally look at what the request says.
The Conversation
Once a connection is open, the browser and the server talk with a set of rules called HTTP, the Hypertext Transfer Protocol. Surprisingly, at its heart, HTTP is plain text that a person can read. The slider below plays out one request from the browser and the answer from the server:
The first line of the request says what the browser wants: GET, the page at the path /index.html. The following lines, called headers, add details, such as which languages the reader prefers. The response starts with a status code: 200 means "here it is". Other codes you may have met are 404, "not found", and 500, "the server broke". After the headers and an empty line comes the page itself, written in HTML, a language that describes headings, paragraphs, links, and images.
One header deserves special attention: the Host line, which repeats the name that the reader typed. Why would the server need that? Because one server, with one IP address, often hosts many websites. Several names can have A records with the same address. The buttons below pick the name in the Host line:
The packets of all three requests arrive at the same address and the same port. Only the Host line tells the server whether the reader wants example.com, example.org, or example.net, so that it can send back the right site. This is how shared hosting fits thousands of small websites on one machine.
HTML was written by Tim Berners-Lee at CERN, together with HTTP and the first browser, between 1989 and 1991. The web is the name for all the pages that link to each other this way. It's one use of the internet, the network we've been building, among many others, like email and video calls. But the HTTP conversation, as we've drawn it, has a serious problem.
Locks
Every packet passes through many machines on its way: the Wi-Fi of a café, the routers of several companies, the equipment of a data center. Any of them could read a packet as it passes, or even change it. In the demonstration below, the laptop logs in to a website from a café. The buttons choose between plain HTTP and its locked version:
With plain HTTP, anyone on the path can read the password as it goes by. With HTTPS, the browser and the server first agree on a secret key, and then scramble every packet with it. The machines on the path still carry the packets, and they can still see the addresses, but the contents look like noise. This locking layer is called TLS, and HTTPS is simply HTTP sent through TLS. The lock in your browser's address bar means the connection uses it.
But scrambling alone isn't enough. If someone on the path could pretend to be the server, the browser would happily agree on a key with the impostor. So the server must also prove that it really is example.com. It does so with a certificate: a short document that says "this key belongs to example.com", signed by a certificate authority, an organization that every browser trusts. The buttons choose who answers the browser:
Before it signs anything, the authority checks that the person who asks really controls example.com, for example by asking them to put a special file on the website. When the real server answers, the browser finds the name it typed in the certificate and checks the signature with the authority's key, which shipped with the browser. An impostor can copy the certificate, but it can't use it: only the real server has the secret half of the key that the certificate names. And it can't forge a new one, because it can't make the authority's signature. Since 2015, an authority called Let's Encrypt gives such certificates for free, and today nearly all web traffic is locked.
With that, we have every piece of the trip. Let's put them together and time them.
The Whole Trip
The drawing below shows everything that happens when you open https://www.example.com for the first time, with time running down the page as before. The browser first asks the resolver for the address, then opens a TCP connection to the server, then agrees on a key, and only then sends its request. The slider sets the round-trip time to the server, and the buttons choose whether the resolver already has the name in its cache:
Notice that the page can't arrive before at least three round trips: one for the handshake, one for the lock, and one for the request itself, plus the lookup if the name isn't cached. With a server 20 ms away, that's hardly noticeable. With a server on the other side of the world, it's most of a second before the first byte of the page arrives.
And the first page is only the beginning. The HTML names other files that the page needs: style sheets that describe its look, scripts that make it interactive, images, and fonts. The browser can only ask for them once it has read the HTML, and some of those files name further files in turn. The chart below shows a small page loading, with one bar for each file. The colors are the steps we've already met: the lookup, the connection, the lock, and the request, where the pale part is the wait for the answer and the solid part is the download. The slider sets the round-trip time again:
The browser opens several connections and asks for many files at once, but it still has to wait for each round of files before it knows the next round. A typical web page today needs several dozen files. As you can see by moving the slider, the total time grows almost in proportion to the round-trip time. That's why the second trick, moving the server closer, matters so much.
Copies Near You
Most of a website is the same for every reader: the images, the scripts, the style sheets, often the pages themselves. Such files can be copied to many servers around the world, and each reader can get them from the nearest copy. A network of such servers is called a content delivery network, or CDN. In the demonstration below, the strip stands for the distance around the world. You can drag the reader along it, and the slider adds copies of the website:
With only the original server, a reader on the far side of the world waits for long round trips. With copies spread around the world, every reader is close to one of them, and the round trips shrink to a few milliseconds. The copies use the same tricks we've already seen: the DNS of the website gives each reader the address of a nearby copy, or many copies share one address with anycast, just like the root servers.
Large websites go further and keep copies of everything in many data centers, but that's a story for another day. Instead, let's return to the demonstration from the beginning, which should now read very differently:
Your computer asks the resolver for the address of the name, and the resolver, if it doesn't have it in its cache, walks down the tree from the root. Your request then leaves your home through the home router, which swaps in its public address, and hops from router to router, each one choosing the next step from the destination address. At the data center it reaches a virtual machine, and the program behind port 443 reads the Host line and sends the page back, in numbered packets that the browser puts back in order. All of this, many times over, for every page you open.
Further Reading
Julia Evans has written some of the friendliest explanations of networking. Her zine "How DNS Works" and her many blog posts at jvns.ca go into the parts of DNS that I skipped, with a sense of humor and many practical commands to try.
Ilya Grigorik's free book "High Performance Browser Networking" is the best next step if the section on round trips caught your interest. It explains TCP, TLS, HTTP/2, and Wi-Fi in depth, always with an eye on what makes pages fast or slow.
The Cloudflare Learning Center has short, clear articles on nearly every term in this article, from DNS records to CDNs and BGP. It's a good place to look up a word when you meet it again.
Finally, for those who like original sources, RFC 1034 is the 1987 document that describes the Domain Name System. It's surprisingly readable, and most of it is still exactly how DNS works today.
Final Words
What strikes me most about the internet is that nobody is in charge of it. There's no central computer and no master map. Tens of thousands of separate networks, run by companies, universities, and governments that often compete with each other, simply agree to follow the same few rules and to pass each other's packets on. Each router only knows its neighbors, each name server only knows its own branch, and yet a packet from your phone finds a machine on the other side of the planet in a fraction of a second.
Most of these rules are older than the web itself. IP and TCP date from the 1970s, and DNS from 1983. They were designed for a few hundred computers at universities, and they now carry the traffic of billions of people, with remarkably few changes. That says a lot about the people who chose to keep each piece small and simple.
The next time a page takes a moment to load, you might picture the trip it's making: the question to the resolver, the walk down the tree, the handshake, the lock, the request bouncing from router to router through glass under the ocean, and the answer making its way back, packet by packet, to put the page together on your screen.