How computers work

The journey of a request: from the browser to a server on another continent and back

You typed the address of an American website and pressed Enter. Half a second later the page is already on the screen, and in that time the request has passed through the OS kernel, the network card, Wi-Fi, the router, the provider’s fiber, an internet exchange point, a backbone across half of Europe, a submarine cable across the Atlantic, a data center’s network core, a server, a database, and then the whole way back. Let’s go through it step by step and count the milliseconds, relying on the models of the “Local network,” “Region,” “Continent” and “Internet and Earth” levels.

Open on the site →

Enter: the browser decides what to do

First the browser parses what was typed: is it an address or a search query? If it is an address, what is the scheme (https), what is the host name, what is the path? Then it checks whether it can manage without the network at all. The cache may hold a fresh copy of the page. The HSTS list may say that this site opens only over HTTPS, and the browser will go straight to the secure protocol. There may already be an open connection to this server, in which case it is reused.

The browser often starts working even before Enter: while you are typing, it guesses the address from your history and resolves the name in advance, or even opens a connection. That is why familiar sites open noticeably faster than new ones.

The network request itself is made not by the tab process (it is sandboxed and not allowed onto the network) but by the browser’s network service. It needs to find out the server’s IP address and establish a secure connection with it. How the browser works inside is covered in the article on the browser; here we are interested in the path through the network.

See also: Inside the browser: from HTML bytes to pixels on the screen · Network and server: how data finds its way and comes back

DNS: a name turns into an address

Computers on the internet know each other only by IP address. The network service first looks in the browser’s DNS cache, then asks the OS, which has its own cache. If the name is not there, the OS sends a query over UDP to port 53 of a recursive resolver: the one specified in the settings, whether in the router, at the provider, or a public one.

If the name is not in its cache either, the resolver walks the hierarchy: a root server points to the servers for the .com zone, those point to the domain’s authoritative servers, and only the latter give the answer: an IP address and the record’s time to live. Each stage is one short exchange of packets, and thanks to anycast the root servers and large servers are usually not far away.

From a cache the answer arrives in 0–20 ms; a full walk takes tens to hundreds of milliseconds. Often the answer contains not the address of a server in America but the address of a nearby CDN node, in which case the whole rest of the path becomes dramatically shorter. For a fair comparison, let’s assume the server really is in New York and the answer cannot be cached.

See also: Network and server: how data finds its way and comes back

Inside our computer

The browser’s network service calls connect(), a system call that asks the OS kernel to establish a TCP connection to the server’s address and port 443. The kernel creates a connection structure, picks a free local port (for example, 51234), builds a SYN segment with a random initial sequence number and wraps it in an IP packet with the destination address.

Then the kernel looks at the routing table: the address is not on our local network, so the packet must be sent to the gateway, the router at 192.168.1.1. The router’s MAC address is already known from the ARP cache. The driver puts the frame into the network card’s queue, and the card fetches it from memory by itself via DMA and sends it out onto the cable or into the air.

This whole step takes tens of microseconds of CPU time. While the connection is being established, the browser thread does not wait actively: it waits for an event via epoll or an equivalent, and the processor is free for other work.

See also: The operating system: who shares out the processor, memory and devices

The apartment: Wi-Fi, router and NAT

The frame reaches the router in microseconds over a cable, or in 1–5 ms over Wi-Fi if the airwaves are busy with the neighbors. The router strips off the Ethernet envelope, looks at the destination IP address and realizes it is headed outside. Our computer has the private address 192.168.1.10, which does not exist on the internet, so the router performs NAT: it replaces the sender’s address and port with its own public address and a free port, and records the mapping in a table so that it can later return the reply to the right device.

Next the packet goes to the ONT optical terminal, which turns the electrical signal into light. Home GPON optical networks share one fiber among dozens of apartments: downstream everyone receives a common stream (up to 2.5 Gbit/s) and takes their own share, while upstream the apartments transmit in turn, in time slots assigned to them. Waiting for your slot adds hundreds of microseconds.

Many providers perform yet another NAT on their side (CGNAT), because there are not enough public IPv4 addresses to go around. With IPv6 there is none of this substitution: every device has its own global address.

See also: Local network: router, switch, Wi-Fi

The city: provider and exchange point

Light travels down the fiber to the provider’s district node, the OLT, and from there to the point of presence (PoP), where the core routers stand. This is where the packet’s next hop is decided: the router looks in a table of about a million routes received via BGP and finds the best path to the network where the destination address lives.

If the server is in our city, the packet passes through an internet exchange point (IX) into the data center’s network, and in the “Region” level model the whole round trip takes about 1.6 ms. From a mobile phone it takes longer: the cellular network’s radio interface adds a few to tens of milliseconds.

But our server is across the ocean. A home provider usually has no cable of its own across the Atlantic, so the packet is handed to a backbone operator, under a paid transit or peering agreement, and heads toward the major European hubs.

See also: City and region: how networks connect

The continent: the backbone to Frankfurt

Next the packet travels over backbone fiber along roads and railways: our city → Minsk → Warsaw → Berlin → Frankfurt. A single fiber carries dozens of channels of different colors (DWDM), each at 100–400 Gbit/s. Every 80–100 km there is an optical amplifier: it amplifies the light without converting it to electricity, so it adds almost no delay.

Routers stand only at the major hubs, and between them light travels through glass at about 200,000 km/s. The overland route is about 30% longer than a straight line: in the “Internet and Earth” level model the stretch to Frankfurt is about 2,600 km, which is about 13 ms one way.

If an excavator cuts the cable, the routers recompute the path within a fraction of a second to a few seconds and send the traffic around it, for example via Saint Petersburg, Helsinki and Stockholm. The connection will not break, but the latency will grow by a few milliseconds; you can see this in the demo at the “Continent” level. Frankfurt is one of the largest traffic exchange hubs in the world, and it is here that the packet enters a network that has capacity across the Atlantic.

See also: Continent: backbones between cities

The ocean: a submarine cable

From Frankfurt to London, then to the cable landing station on the west coast of England, and onward along the floor of the Atlantic. A submarine cable as thick as a garden hose (thicker near the shore, with armor) contains several fiber pairs, each pair carrying tens of terabits per second. Every 50–100 km, repeater amplifiers sit on the seabed, powered by direct current at up to 15–18 kV fed from the shore through the copper sheath of the cable itself.

The ocean crossing itself is about 5,700 km, roughly 28 ms. The whole route from our city to the server in New York is about 9,600 km in the model and about 49 ms one way, even though the cities are 7,500 km apart in a straight line. Even light in a vacuum along a straight line would take 50 ms there and back; the laws of physics will not let any technology go faster.

For comparison, the model has two more paths. Via low Earth orbit satellites (at an altitude of about 550 km, with laser links between satellites; in glass, light is roughly a third slower than in a vacuum, by a factor of 1.47) it is about 79 ms round trip, even a little faster than cable over such a distance. Via a geostationary satellite at an altitude of 35,786 km it is about 560 ms: the signal travels about 80,000 km up and down in each direction.

See also: Internet and Earth: cables and satellites

Handshakes: why one request means several round trips

Our first packet is only a SYN, a request to set up a connection. The server replies with SYN-ACK; that is the first full round trip, about 100 ms. Then the TLS 1.3 handshake begins: the browser sends its greeting with half of the key exchange, and the server replies with its half, its certificate and a signature; that is the second round trip. The browser checks the certificate and only now sends the HTTP GET request itself. The response with the first bytes of the page arrives after the third round trip.

In total: DNS (if not cached) plus three round trips of 100 ms each, about 0.3–0.4 s to the first byte, even though the server itself may have answered in 5 ms. That is why latency matters more than bandwidth: a gigabit link gives you nothing while the protocols are exchanging short messages back and forth.

Shortcuts have been invented at every step. HTTP/3 over QUIC combines the transport and encryption setup into a single round trip. On a repeat visit, TLS 1.3 and QUIC allow the request to be sent right in the first packet (0-RTT). The browser keeps connections open and reuses them for subsequent requests. But the most powerful technique is a CDN: if a server with a copy of the content stands in our city, a round trip takes not 100 ms but 2–5 ms.

See also: Network and server: how data finds its way and comes back · Internet and Earth: cables and satellites

The data center: from the entrance to the rack

In New York the packet arrives at the data center over the city’s fiber. The providers’ fibers enter a separate room, the meet-me room, where they are connected to the equipment of carriers and tenants. Edge routers filter out attacks, cutting off unwanted traffic, and pass the packet to a load balancer.

The load balancer picks one of many identical servers capable of answering, based on load, a hash of the client’s address, or availability. It is often the load balancer that terminates TLS: it decrypts the traffic and passes plain HTTP onward over the secure internal network. Inside the data center the network is built on a “spine-leaf” design: every rack switch is connected to all the core switches, so any two servers are separated by 3–5 hops and tens of microseconds.

The switch at the top of the rack passes the packet to the network card of the right server; in the model this is a 2 × 100 Gbit/s card connected to its own rack’s switch.

See also: Data center: where websites live

The server: an answer in milliseconds

The server’s network card writes the packet into memory via DMA and raises an interrupt. The OS kernel checks the checksums, finds the right connection by addresses and ports, puts the data into the socket buffer, and the epoll mechanism tells the server program (for example, nginx) that the connection is ready to be read. The program reads the request “GET /,” decrypts it if TLS terminates here, and decides what to do.

A static file is sent right away, often straight from the OS page cache without reading the disk. A dynamic page requires work: the application server checks the cookie, makes several requests to an in-memory cache and to the database (each a fraction of a millisecond inside the data center), fills the data into a template and generates the HTML. A well-written service fits into 5–50 ms; a poorly written one can think for seconds.

The finished response, usually compressed (gzip or Brotli shrink HTML 4–8 times), is written into the socket. The kernel cuts it into TCP segments of 1,448 bytes, and the network card sends them out via DMA. In the first round trip the server can send only about 14 KB (this is how TCP slow start works), and if the page is larger, each subsequent batch doubles but waits for acknowledgment, another round trip across the ocean.

See also: Databases and apps: how to find one row among billions · Server: a computer for the data center

Back and onto the screen

The response travels back by the same route, though not necessarily over the same cables: each network chooses its own route, and the paths there and back sometimes differ. Across the ocean, along the backbone, through the city, to the router (which, by reverse NAT, hands the packet to our computer), and into the network card, the OS kernel, the socket and, finally, the browser’s network service.

As soon as the first kilobytes of HTML arrive, the tab process starts parsing, finds links to stylesheets, scripts and images, and requests them. If they are on the same server, the already open connection is used; if they are on other servers, DNS and the handshakes are repeated for each new server. A modern page is 50–100 resources and 1–3 MB of data, so a full load takes several round trips and usually 0.5–2 s.

To sum up for a page from New York without a CDN: about 0.3–0.4 s to the first byte, plus another 0.2–0.5 s for stylesheets, scripts and the first paint. About 100 ms of every round trip is physics: the time it takes light to travel the path through glass. Everything else is protocols, queues and programs, and it is these that engineers spend years optimizing. You can walk the whole path in the model, climbing from the “Local network” level to the “Internet and Earth” level and peeking into the “Network” layer of the software side.

See also: Inside the browser: from HTML bytes to pixels on the screen · Internet and Earth: cables and satellites

Open on the site →

All articles

Overviews

Logic: from transistor to arithmetic

Processor

Computer

Servers and data centers

Networks and the internet

Software