Home › Topics › Website & Web-Service Uptime Monitoring › Layers of a Web Check

DNS, TLS, HTTP: The Layers of a Single Web Check


"The website check failed" is one of the least useful sentences in monitoring. It sounds like an answer, but it is really a question with five or six possible meanings. The name might not have resolved. The server might have refused the connection. The certificate might have expired at midnight. The application might have hung while the network was perfectly fine. Every one of those is "the check failed," and every one sends you to a different person, a different console, and a different fix.


This guide takes a single web check apart. You will see the six stages every request passes through and what a healthy timing profile looks like. You will learn how to measure each stage yourself with a command-line tool. Most usefully, you will learn which stage points at which culprit. By the end, a failed or slow check will tell you where it failed. You will have per-stage thresholds that catch a layer drifting before the whole page falls over.


In this guide

  • One check, six stages
  • What a healthy timing profile looks like
  • Measuring the stages from the command line
  • Stage by stage: what failure and slowness implicate
  • The stage-to-culprit table
  • Certificates: part of every check, not a separate hobby
  • Building per-stage thresholds
  • Two annotated examples
  • Where to go next

One check, six stages


Think of a web request as phoning a business. First you look up the number. Then you dial and wait for someone to pick up. Then you confirm you have reached the right company and agree to speak privately. Then you ask your question. Then you wait while they find the answer. Finally you listen to the whole reply. A web check goes through the same six steps, and each one can fail or stall independently.


  • DNS resolution. The checker asks a resolver (a DNS server that answers lookups on its behalf) to turn www.example.com into an IP address. The resolver may answer from its cache or go and ask your domain's authoritative name servers, the servers that hold the official records.
  • TCP connect. The checker opens a connection to that address on the web port. This is a round trip across the internet: a packet goes out, an acknowledgment comes back.
  • TLS handshake. For an https address, the two sides negotiate encryption. The server presents its certificate (a signed statement that this key belongs to this name). The checker verifies it against a chain of trusted issuers. The two sides agree on a protocol and cipher. This is one or two more round trips.
  • Request sent. The checker sends the actual HTTP request: the method, the path, the headers. This is usually instantaneous once the connection exists.
  • First byte. The checker waits for the first byte of the response. The gap between sending the request and receiving that byte is the time to first byte. It is almost entirely the server thinking: running code, querying a database, waiting on another service.
  • Full body. The rest of the response streams in. How long this takes depends on the size of the page and the bandwidth of the path. It also depends on whether the content is compressed, and whether it is served from a nearby cache or a distant origin.

A check that reports only "up" or "down" collapses six stages into one bit. A check that reports only total time collapses them into one number. Both throw away the most useful thing the request produced: which stage went wrong.


What a healthy timing profile looks like


Exact numbers depend on distance, hosting, and the page, so treat this as shape, not law. For a checker a few hundred kilometers from the server, DNS usually takes a few milliseconds when the resolver has the answer cached. When it has to go and ask, DNS usually takes a few tens of milliseconds. The TCP connect is roughly one network round trip. The TLS handshake is one to two round trips plus a little computation. The first byte arrives after the connect and handshake plus however long the application takes to build the response. That application time is where most of the variation lives. The body takes as long as the bytes take to travel, which for a modest page is small, and for a huge one is not.


Two features of this shape matter for monitoring. First, the network stages (DNS, connect, TLS) are stable. On a healthy path they vary by a few milliseconds from check to check. So a jump in any of them is a strong signal. Second, the first-byte stage is noisy. It wobbles with server load, caching, and whatever the database is doing. So a single slow reading means little while a sustained rise means a lot. Thresholds should respect that difference, and further down we build them that way.


Measuring the stages from the command line


The quickest way to see the stages is curl, which is available on nearly every system and can print a timing breakdown for any request. The following command fetches a page, discards the body, and prints when each stage completed. The variables are cumulative: each one is seconds since the command started.


curl -sS -o /dev/null -w "dns        %{time_namelookup}\nconnect    %{time_connect}\ntls        %{time_appconnect}\nfirstbyte  %{time_starttransfer}\ntotal      %{time_total}\nstatus     %{http_code}\n" https://www.example.com/

Output from a healthy site looks something like this (illustrative values):


dns        0.018
connect    0.041
tls        0.089
firstbyte  0.214
total      0.262
status     200

Because the numbers are cumulative, the time spent in each stage is the difference between neighbors. Here DNS took 18 ms. The connect took 23 ms (41 minus 18). The handshake took 48 ms (89 minus 41). The server took 125 ms to produce its first byte (214 minus 89). The body took 48 ms to arrive. Total: 262 ms. Written out that way, the request stops being one number and becomes a profile you can compare against yesterday's.


A few switches make the tool more useful for diagnosis. --resolve www.example.com:443:203.0.113.10 forces a specific address for the name, which lets you test the server while bypassing DNS entirely. If the check works with --resolve and fails without it, DNS is your problem. -v prints the handshake details, including which certificate the server presented and whether verification passed. --connect-timeout 5 and -m 20 cap the connect stage and the whole request. That way, a hung server produces a clean timeout instead of a check that never returns. And -L follows redirects, which you sometimes want and sometimes very much do not.


Warning: never put -k (skip certificate verification) in a monitoring check to make a red light go green. A check that ignores certificate errors will report a site as healthy while every browser on earth shows a warning page. If verification fails, that is the outage.


Stage by stage: what failure and slowness implicate


DNS

A failure here means the name could not be turned into an address, and the shape of the failure narrows it down. A "no such name" answer means the record is missing or misspelled, or the whole domain has gone. An expired registration is the classic cause, and it takes down every name under the domain at once. A "server failure" answer or a timeout means the resolver could not reach your authoritative name servers, or they are misconfigured. If the same name resolves fine through a different resolver, the problem is on the resolver's side rather than yours. Slow DNS with correct answers usually means slow authoritative servers or a struggling resolver. Whatever the cause, the people who can fix it are whoever manages your registrar account and your DNS hosting.


TCP connect

The name resolved, but nothing answered on the port. "Connection refused" means a host answered and said nothing is listening. The web service is stopped, or it is listening on a different port or address than the one the record points at. A connect timeout, where nothing comes back at all, means the packets are being dropped. The host is down, a firewall is silently discarding the traffic, the address is wrong, or the route to it is broken. Slow connects that eventually succeed point at a congested or lossy path, or a host so overloaded it is slow to accept connections. The culprits are the hosting provider, the network path, and your own firewall rules.


TLS handshake

The connection opened but the two sides could not agree to talk securely. The usual causes are almost boringly consistent. The certificate has expired, or it is for a different name than the one requested. A name mismatch is common after a hostname change or when a default certificate is served. Or the server sent an incomplete chain, so the checker cannot trace the certificate back to an issuer it trusts. Or the two sides support no protocol version or cipher in common. That happens when one side is very old or very strictly configured. Clock problems on either end can make a valid certificate look expired or not yet valid. A slow handshake is rarer, and typically means an overloaded server, a very large chain, or a slow check of the certificate's revocation status.


Request to first byte

Everything up to here was plumbing; from here on it is the application. A long wait for the first byte means the server is working on the request. The application is slow, the database is slow, or a service the page depends on is slow. An error status code arriving here means the application ran and reported failure. A timeout with no response at all means the application is hung or the request queue is full. This is the stage that belongs to the developers and whoever runs the database.


Body

The response started but took a long time to finish, or was cut off. One usual reason is size (a page that grew from a few hundred kilobytes to several megabytes). Another is bandwidth on the path. It might be a content delivery edge that is missing the cache and pulling from a distant origin. Or it might be a backend that streams the page slowly because it is generating it as it goes. A body that ends early or fails a content match points at an application error in the middle of the page, or at a proxy that closed the connection.


The stage-to-culprit table


Pin this near the on-call desk. It maps the stage that failed or slowed to the likely cause and the first person to call.


StageFailure looks likeSlowness looks likeFirst suspectsFirst call
DNSNo such name; server failure; lookup timeoutLookups taking hundreds of milliseconds or moreExpired domain, deleted or wrong record, unreachable or misconfigured name servers, a struggling resolverRegistrar account holder; DNS hosting
TCP connectConnection refused; connect timeoutConnects taking many round tripsWeb service stopped, wrong port or address, host down, firewall dropping traffic, broken route, saturated linkHosting provider; whoever owns the firewall
TLS handshakeExpired certificate; name mismatch; unknown issuer or incomplete chain; no common protocol or cipherHandshakes much slower than the connectCertificate renewal missed, wrong certificate deployed, chain file incomplete, protocol settings changed, clock skewWhoever renews and deploys certificates
First byteError status code; no response before timeoutLong server think timeApplication error, hung process, slow or locked database, slow dependency, full request queueDevelopers; database administrator
BodyTruncated response; content match failsLong transfer after first bytePage size growth, bandwidth, cache misses at the edge, slow streaming backend, proxy closing earlyDevelopers; edge or CDN operator

Notice how the "first call" column changes as you move down the table. That is the practical payoff of per-stage checks: they route the outage to the right people on the first attempt instead of the third. The guide on triaging a website outage turns this table into a ten-minute sequence.


Certificates: part of every check, not a separate hobby


Certificate problems deserve special attention because they are the only outage that is scheduled in advance and still surprises people. Every certificate carries an expiry date; on that date the site stops working for everyone with a browser, and nothing else about the server has changed. Internal monitoring almost never sees it, because internal checks tend to hit a different listener or use a different name. Or they were told to ignore certificate errors long ago by someone who was busy.


So every HTTPS check should verify the certificate the way a browser does: the name matches, the chain leads to a trusted issuer, and the dates are valid. Beyond pass or fail, the check should also record how many days remain until expiry. It should raise a warning well ahead of the date, in a window long enough to renew and deploy without drama. Checking the chain matters as much as checking the leaf certificate. A server that sends only its own certificate without the intermediate issuer will work in some browsers, which cache intermediates, and fail in others. That is exactly the kind of "works for me" problem that wastes an afternoon. The certificate expiry monitoring guide covers the warning windows and renewal workflow in depth; here the point is simpler. The certificate is a stage of the web check, and it gets a threshold like any other.


Building per-stage thresholds


A threshold on total response time catches the big failures but hides the slow drift of one layer. If DNS creeps from 20 ms to 400 ms, the total goes from 260 ms to 640 ms. That may still be under a total-time threshold while being a clear sign that your name servers are in trouble. Per-stage thresholds catch that. Here is a method that works without guessing.


  • Step 1: record the stages, not just the total. Store DNS, connect, TLS, first byte, and total for every check, from every location. Most checkers can do this; if yours cannot, the command above in a scheduled script can.
  • Step 2: collect a baseline. Run for a week or two so the numbers include busy hours, quiet hours, and a weekend.
  • Step 3: take a high percentile per stage. For each stage, find the value that most checks stayed under. Use a high percentile rather than the average, so one bad reading does not skew the baseline. The guide on response-time budgets explains the percentile approach properly.
  • Step 4: set warning and critical levels. A workable rule of thumb is warning at roughly double the baseline percentile. Set critical at several times that percentile or at a hard ceiling users would notice, whichever is lower. Require the condition to hold for several consecutive checks before alerting, especially on the noisy first-byte stage.
  • Step 5: review quarterly. Sites change. A page redesign moves the body stage; a database migration moves first byte; a move to a new host moves everything.

If you need a place to start before the baseline exists, the table gives conservative values for a checker on the same continent as the server. They are starting points to be replaced by your own data.


StageWarning (sustained)CriticalNotes
DNSabove 200 msabove 1 s, or any lookup failureVery stable normally; a jump is meaningful even when small
TCP connectabove 300 msabove 2 s, or refused, or timeoutCompare against your normal round trip from that location
TLS handshakeabove 500 msany verification failure; expiry inside your renewal windowVerification failures are outages, not slowness
First byteabove 800 msabove 3 s, or an error statusNoisy; require several consecutive breaches
Totalabove 2 sabove 5 s, or content match failureThe user-facing number; keep it, but do not rely on it alone

Tip: alert on the stage, and say so in the message. "First byte 3.1 s (baseline 0.2 s), DNS and TLS normal" sends the on-call person to the application immediately. "Website slow" sends them everywhere.


Two annotated examples


The best way to make the stages stick is to read a couple of real-looking profiles. Both use the command from earlier against the same site as the healthy profile above.


Example 1: the application is struggling

dns        0.017
connect    0.040
tls        0.087
firstbyte  4.912
total      4.966
status     200

DNS, connect, and TLS are identical to the healthy run, so the network path and the certificate are fine. The first byte took nearly five seconds, and the body arrived quickly once it started. The server spent almost all of that time thinking. This is an application or database problem. And the status code of 200 means the page eventually rendered; customers are getting a slow site, not a broken one. First call: developers and the database administrator, with a question about what changed and whether a query is locked or a dependency is timing out.


Example 2: the certificate has expired

curl: (60) SSL certificate problem: certificate has expired
dns        0.019
connect    0.043
tls        0.000
firstbyte  0.000
total      0.061
status     000

The name resolved and the connection opened, then the handshake failed and every later stage reads zero because they never happened. The error text names the cause outright. Note the trap: a check with verification disabled, or a plain TCP port check, would report this site as up. That is because the port is open and the server is running. Only a check that verifies the certificate sees what customers see. First call: whoever renews certificates, and then a look at why the expiry warning did not fire, or did fire and went unread.


Once you can read profiles like these, an external check becomes a diagnostic tool rather than a smoke alarm. Pair the stage breakdown with checks from more than one location and you can tell which layer failed. You can also tell whether it failed for everyone or for one corner of the internet.


Where to go next


A web check is a six-stage journey. It resolves the name, opens the connection, and agrees on encryption. It sends the request, waits for the first byte, and receives the body. Each stage has its own failure modes, its own normal timing, and its own set of people who can fix it. Record the stages separately, baseline them, threshold them individually, and verify the certificate every single time. Do that and "the website check failed" turns into "DNS failed" or "first byte is ten times normal," which are sentences you can act on.


From here, Response-Time Budgets takes the timing side further and shows how to decide what "fast enough" means for each page. And Monitoring What Customers Actually Touch covers choosing which pages and flows to run these checks against. Both are part of the Website & Web-Service Uptime Monitoring topic, which also holds the multi-location and outage-triage guides this one leans on.


Put this into practice with SysPeep Monitor

When a stage in the web check goes bad, the next question is what is happening on the machine behind it. SysPeep Monitor watches the web servers, database hosts, firewalls, and links behind your site over SNMP, WMI, and SSH. Its thresholds and dependency-aware alerting point at the layer that moved. Put it beside your outside-in checks and the free trial will show you the inside of the next slow first byte.

Download Free TrialLearn About SysPeep