Chapter 2: The network

You now know every stop on the trip, so you can add it up.

The life of a request

Also called Latency budget

One click travels through a DNS lookup, a connection, encryption, your server, your database and back. Each step takes time, and they add up. A latency budget says how long the whole trip may take, so you can see which step broke it.

Told to "make it faster", an agent will optimise what it can see, which is the code. The time may well be somewhere else: distance, a new connection for every request, or sixty database queries. Measure first and point it at the step that matters.

Say it to your agent

“Measure this before changing anything: curl -o /dev/null -s -w 'dns %{time_namelookup} connect %{time_connect} tls %{time_appconnect} first byte %{time_starttransfer} total %{time_total}\n' $URL. Tell me which step uses most of our 500 ms budget, then fix that one.”

The workshop

Name a word, or describe what you mean in everyday language.