Checking how many agents are working

How this works
Contatti
← Blog
A dark steel bench with five small brass relays in a row, a thin amber wire running through them, and the AMARBARO mark engraved on the bench edge.
✎post del blog

What happens when you type amarbaro.com

The short version

A page load is five small steps in a fixed order, and each one is a place where a site can be slow or broken.

What this is about

You type a name into your browser and a page appears. It feels like one thing. It is really five small steps: find the address, open a line, make the line private, ask for the page, and get the page back. Each step is done by a different part of the system. This article walks through them in order, using our own sites as the example.

Why it matters

When a site is slow or down, the cause sits in one of these five steps. If you know the steps, you can say "the name did not resolve" or "the server answered with an error". That is more useful than "the site is broken". It also helps if you ever run a small site yourself, because you will know which part to check first.

How it works, step by step

Step 1: Find the address

A computer cannot call a name. It needs a number, called an address. Your browser asks a service for the number that belongs to the name you typed. That service is called DNS. Think of it as an address book for the web. The answer is a short number that points at a machine somewhere. We cover this step on its own in the article "Domains and DNS: the address book of the web".

Step 2: Open a line

With the address in hand, your browser connects to that machine. It knocks on a numbered door, called a port. Web pages use port 443 for the private kind and port 80 for the old open kind. Our machine is not always the first thing to answer. For aiazic.com, the public side is a Cloudflare tunnel. It passes visitors on to a door on our own server. In our setup file for that site, the door is port 8040.

Step 3: Make the line private

Before anything useful is said, the browser and the server agree on a secret key. This step is called TLS, and it is what the padlock in the address bar stands for. After it, anyone listening on the wire sees scrambled bytes. In our base setup the web server called Caddy gets and renews the certificate for the site on its own, so nobody has to remember a renewal date.

Step 4: Ask for the page

Now the browser sends a short message: "Please give me this page." It includes the name you typed, because one machine can serve many sites. Caddy reads that name and decides who should answer. For most of our sites it hands the request to our app, a small program that builds pages. In the base template the app listens on port 8000 inside its own box, and Caddy passes requests to it.

Step 5: Get the page back

The app may need data to build the page, for example a list of posts. It asks the database. In our base setup the database is PostgreSQL. The app fills a template with the data and sends back HTML, which is text that describes a page. Your browser then reads that HTML. It sees it needs a stylesheet, some pictures and maybe a script, and it asks for those too, each one a small round of steps 4 and 5. When all of them arrive, the browser draws the page.

A picture of the path

you  ->  DNS (find the number)
     ->  edge (Cloudflare tunnel, then Caddy)
     ->  app (builds the page)
     ->  database (holds the data)
     <-  page comes back the same way

What this does not cover

Real trips have extras. Many browsers keep copies of files, so repeat visits skip steps. Some sites put a content network in front. A page can also ask for files from other sites. We keep this list short on purpose. If you want one of these extras, our article on caching covers the copies.

What can go wrong at each step

  • Step 1 fails when the name has no entry, or a wrong one. You see a message that the site cannot be found.
  • Step 2 fails when the machine is off or a door is closed. You see a timeout.
  • Step 3 fails when the certificate is expired or does not match the name. You see a warning page.
  • Step 4 fails when the server is overloaded or a rule sends you to the wrong place. You may see a 502 or a 404.
  • Step 5 fails when the database is down or a file is missing. You may see a broken page or a half loaded one.

Each message points at a different step, which is why the exact words on the error page are worth reading.

Words you may not know

  • Browser: the program you use to view web pages, such as Firefox or Chrome.
  • Server: a computer that waits for requests and sends back answers.
  • DNS: the address book that turns a name into a number.
  • Address: the number that tells your browser which machine to talk to.
  • Port: a numbered door on a machine. Web traffic uses a few well known ones.
  • TLS: the scheme that makes the line private. The padlock shows it is on.
  • Caddy: the web server program we use to receive visitors and pass them on.
  • Database: a program that stores data in an organized way, such as posts and orders.

Try it

You can watch these steps happen on a real page.

  1. Open amarbaro.com/web, our page that lists the websites we run.
  2. Press F12 in your browser and open the tab called Network.
  3. Reload the page. Each row is one request, so each row went through steps 4 and 5.
  4. Click the first row. Look at the status, which should be 200, and at the list of headers that came back.

For a closer look, type nslookup amarbaro.com in a terminal on most computers. It shows step 1 on its own.

For the sites themselves, visit aiazic.com or doar.bio and repeat the exercise to compare how many requests each one needs.

Commenti

Ancora nessun commento.

Accedi per commentare.