Why loading a page takes several round trips
A round trip is a message out and the reply back. A page load needs several of them before the server runs any of your code.
You type the web address of a food delivery app into your browser and press Enter. The screen stays blank for a moment, then the page appears. The same page opens faster for some users than for others, even when the server's code takes the same time for everyone.
The browser completes these steps in order. Each of the first three needs at least one round trip.
- DNS lookup: find the server's address from its name.
- TCP handshake: open a connection.
- TLS handshake: agree on encryption.
- Request: send
GET /courses. - Server handler: your code runs.
- First byte: the reply starts to arrive.
More detail
The server handler is the function in your code that handles this request, and it may query the database. DNS finds the server's numeric address from its name. The TCP handshake is a short exchange of three messages. The TLS handshake takes two round trips in this model.
Press Play to watch the steps in order. Then drag the slider to the right to move the server farther away, and see which bars grow.
More detail
The numbers are illustrative. Besides your code's 40 ms and the time on the wire, each step has a small fixed processing time in the DNS server and in the handshakes.
Suppose a bigger server cuts the handler from 40 ms to 10 ms. A user in Berlin saves 30 ms. The setup steps still need about five round trips over a long distance, so most of the wait remains.
More capacity speeds up the handler step. Distance depends on where the server sits.
You can now say when a faster server helps and when only a closer one does.
More detail
Regions and failover covers choosing a location close to your users. Server capacity covers what a bigger server changes.