Network troubleshooting: layer-by-layer bisection with curl, dig, mtr, tcpdump and ss

Bisect the path layer by layer with one command per layer, and capture on both ends at once — one end cannot tell 'never sent' from 'never arrived'.

Read the briefing
About 9 min to read 8 drills

What to remember

  1. Work the layers in order: link, address, route, name, port, TLS, application. One command each. The first failure is your answer and the rest is noise.
  2. Two simultaneous captures or none. SYNs leaving A but not reaching B is the path; arriving with no SYN-ACK is B.
  3. mtr beats traceroute for intermittent loss. It samples continuously, so you see which hop loses packets rather than a single snapshot.
  4. ICMP working proves almost nothing. MTU, port filters and conntrack exhaustion all fail while ping succeeds.
  5. Ask what changed before you theorise. Deploys, config, traffic shape, data volume. Recent-incident memory is a bias to declare, not expertise.

The big picture

Network troubleshooting is where an SRE interview stops asking what you know and starts watching how you think. The toolset is small — dig, ss, nc, openssl s_client, curl, mtr, tcpdump — but the score comes from method: reproducing with the smallest tool that isolates one layer, from the vantage point nearest the failure, changing one variable at a time, and saying what each result rules out. Almost every "the site is slow" and "the balancer returns 503 but everything is green" question yields to the same bisection.

The mental model

Picture a request as a stack of layers — name, TCP, TLS, HTTP, backend — each with one tool that isolates it, crossing a row of hops and pool members. Bisect vertically by layer and horizontally by hop or member, one variable per test, from the vantage point nearest the failure, keeping a ledger of what each result rules out. Whenever a check passes while traffic fails, find the variable that differs between the two.

In depth

The method: smallest tool, nearest vantage point, one variable

Turn the complaint into a reproduction before touching anything: one URL, one client and location, one time, and whether it fails or is merely slow. Then ask the question that halves the search space fastest — everyone or a subset? Everyone points at something shared (DNS, the edge, the balancer, a deploy); a subset points at one path, one pool member, or one client population. The SLI dashboard answers that in thirty seconds.

Then bisect by layer with the smallest tool that exercises only that layer:

layer tool a pass proves
name dig +short host @resolver / getent hosts host the resolver (or glibc, with its search list) returns an address
TCP reachability nc -vz host port, ss -tan a SYN gets a SYN-ACK on that port
TLS openssl s_client -connect host:443 -servername host chain, name and protocol negotiate
HTTP curl -sv the request is answered, and by whom
path mtr --report, tcpdump where packets stop; whether the SYN left or arrived

Vantage point matters more than tool choice. A test from your laptop proves your laptop's resolver and path, not the proxy's. Run the reproduction on the failing host or the nearest one you can reach, and run the same command on a host that works: the diff is the finding.

Change one variable per test and say which. curl --resolve host:443:IP swaps which backend answers while keeping Host, SNI and certificate verification intact; dig @server swaps which resolver answers; --http1.1 swaps the protocol; a different source port swaps the ECMP path. Two variables changed at once is a result you cannot attribute.

Keep a ledger in the incident channel — each command, its result, what it rules out: "TCP connects to all six backends from the proxy, so not a filter; TLS negotiates, so not the cert; curl -w puts 2.4 s before the first byte, so server side." It stops you re-running tests and lets the incident commander follow. And the moment a check passes while traffic fails, stop and name the variable that differs between them: port, path, source address, protocol, or zone.

curl -v and curl -w: the layer trace you get for free

curl -v runs every layer in order and stops at the first one that breaks, so it is the natural first reproduction. Read the * lines as a checklist:

*   Trying 203.0.113.10:443...              DNS done: this is the address chosen
* Connected to api.example.com port 443     TCP handshake done
* TLSv1.3 (IN), TLS handshake, Certificate  chain received
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
*  subject: CN=api.example.com              name verified
* ALPN: server accepted h2                  protocol negotiated
> GET /v1/orders HTTP/2                     request left
< HTTP/2 503                                answered — by whom? read server:, body, proxy headers

For slow rather than broken, switch to -w. Its time_* variables are cumulative seconds since curl started, so the diagnosis is a subtraction:

  • time_namelookup → DNS
  • time_connect − time_namelookup → TCP handshake, about one RTT
  • time_appconnect − time_connect → TLS, about one RTT on TLS 1.3 (two on 1.2) plus certificate work
  • time_starttransfer − time_appconnect → request sent and the server thinking: time to first byte
  • time_total − time_starttransfer → body transfer

A line like 0.004 0.031 0.078 2.514 2.531 therefore reads: DNS 4 ms, TCP 27 ms, TLS 47 ms, server 2.44 s, body 17 ms — the problem is the server, and nothing on the client side deserves another minute. Run it three times before believing one; add %{remote_ip} to record which address served, %{http_code} so you notice a fast error, and -o /dev/null -s to keep the body out of the way.

Two options turn curl into a bisection tool. --resolve host:port:IP preloads curl's DNS cache so the request goes to one chosen backend while the URL, Host header, SNI and certificate check stay honest — the way to hit pool members one by one. --connect-to host:port:otherhost:otherport does the same by hostname. Avoid -k unless you are deliberately testing past a certificate failure, and say so in the ledger, because a -k success hides exactly the fault a real client would hit.

Path tools: traceroute, mtr, tcpdump — and the loss that isn't

traceroute and mtr send probes with increasing TTL. Each router that decrements a TTL to zero must generate an ICMP time-exceeded reply, and that is control-plane work: routers rate-limit it (RFC 1812 §4.3.2.8) and handle it after forwarding. So a row showing 40% loss or a 200 ms spike at hop 3 while the destination shows 0% and 30 ms is a router being stingy with replies, not a router dropping your packets. Real forwarding loss begins at a hop and persists to every later hop, because their probes cross the same router. Read the last hop first; a row of ??? is a router that never answers; a jump in RTT that persists to the end marks where the long link or the congestion begins.

Make the probe resemble the traffic. Firewalls that drop UDP and ICMP probes usually pass the application's port, and ECMP routers hash each flow onto one of several paths, so mtr -T -P 443 --report -c 100 host (TCP SYNs to the real port) sees what the application sees; keeping the source port fixed keeps the ECMP path fixed, which is the idea behind Paris traceroute. mtr toward an anycast or load-balanced address measures whichever site your flow hashed to.

When two hosts disagree, tcpdump decides who is lying. On the sender, tcpdump -ni any 'tcp port 8080 and tcp[tcpflags] & tcp-syn != 0' proves whether the SYN left the host at all; the same capture on the receiver proves whether it arrived. SYN present on one side and absent on the other names a filter, route, or security group between them; SYN present on both with no SYN-ACK names the listener or its backlog. Capture both ends at once when you can, write with -w file.pcap and read offline, and remember that on the receiver tcpdump sees a packet before the host firewall does — so a SYN visible in the capture that never produces a SYN-ACK was dropped on that host, by its own filter rules or a full accept queue, not on the path.

Reading ss: states as diagnoses, queues as numbers

ss is the TCP state machine made visible, and each state is a diagnosis:

state who is waiting for whom usual cause
SYN-SENT we sent SYN, no SYN-ACK path, firewall, dead host, or a listener whose full backlog silently drops SYNs
SYN-RECV (server side) we sent SYN-ACK, no ACK SYN flood, or clients that cannot reach us on the return path
ESTAB, Send-Q growing peer not acknowledging peer stalled, zero window, or path loss
ESTAB, Recv-Q growing our application not reading app blocked, GC pause, exhausted thread pool
CLOSE-WAIT peer sent FIN, our app has not called close() file-descriptor leak in our process; no kernel timer clears it
FIN-WAIT-2 we closed, peer has not peer application not closing; expires after tcp_fin_timeout
TIME-WAIT we closed first normal; 60 s per connection; counts against ephemeral ports

Recv-Q and Send-Q change meaning by state. On a LISTEN socket, Recv-Q is the current accept-queue depth and Send-Q is its limit (the backlog), so ss -ltn showing 129 128 means the queue is full and the kernel is dropping SYNs. On an ESTAB socket, Recv-Q is bytes received but not yet read by the application and Send-Q is bytes sent but not yet acknowledged by the peer.

Three invocations cover most incidents. ss -tlnp shows who listens where and catches the classic "works on the host, refused from outside": a process bound to 127.0.0.1:8080 instead of 0.0.0.0:8080. ss -tan | awk 'NR>1{print $1}' | sort | uniq -c is a histogram of states; a pile of any one state points at its owner in the table. ss -tanpo state established '( dport = :5432 )' filters by peer and shows the timers and the owning process. Pair them with the kernel's counters: nstat -az TcpExtListenOverflows TcpExtTCPSynRetrans TcpRetransSegs says whether the accept queue overflowed, whether SYNs are being retried, and whether the path is losing segments — three numbers that settle arguments faster than any packet capture.

Partial failures and 503s with healthy backends

A failure rate that sits at a suspiciously round fraction is a fingerprint. Behind an even balancer, one bad member out of N fails 1/N of requests at random; behind a hash or cookie-sticky balancer, the same bad member fails 100% of requests for 1/N of clients; across an ECMP fan-out, one bad link fails 1/N of flows, so a client's fate depends on its source port. Isolate by member before changing anything global: hit each backend directly with curl --resolve host:443:IP and compare, or read the upstream identifier the balancer already records (Envoy %UPSTREAM_HOST%, nginx $upstream_addr, HAProxy's server name in the log line) and group failures by it. For ECMP, vary the source port and watch which flows fail. Drain the bad member as mitigation; then fix whatever let it stay in rotation.

The other classic — the balancer returns 503 while every backend dashboard is green — is always a disagreement between the health check and real traffic. They differ in one of a short list of variables: port (check on an admin port, traffic on the app port), path (/healthz returns 200 from a process that cannot serve /api), source address (a firewall rule admits the checker's range but not the data plane; cloud health checkers often probe from published ranges distinct from the balancer nodes), protocol or SNI (plaintext check, TLS traffic to a backend that needs SNI), zone (zero healthy backends in one zone with cross-zone balancing off), or limits (the check passes on a backend that is at its connection cap, so requests queue and time out).

Start with the balancer's own account, not the backends'. nginx writes connect() failed (111: Connection refused) while connecting to upstream or upstream timed out; Envoy stamps response flags — UF upstream connection failure, UH no healthy upstream, UT upstream timeout, UO overflow; HAProxy logs a termination state — SC server refused, sQ expired in the queue, sH server timeout waiting for headers. That single field says whether the proxy tried a backend, which one, and how it failed — after which one curl --resolve from the proxy's vantage point usually ends the search.

Myths and facts

Myth: Loss at hop 3 in mtr means hop 3 is dropping our traffic.

Fact: Each row is a router answering probes with ICMP, which is rate-limited control-plane work; real forwarding loss starts at a hop and persists to every later hop. Read the last hop first.

Myth: ping works, so the network is fine.

Fact: ICMP echo proves layer-3 reachability for ICMP. Port filters, MTU black holes, TLS and HTTP failures all coexist with a perfect ping; test the layer and the port the application uses.

Myth: dig resolves the name, so DNS is not the problem.

Fact: dig ignores the search list and ndots by default and may talk to a different resolver than glibc does; getent hosts name reproduces what the application actually sees.

Myth: The balancer shows every backend healthy, so the backends are fine.

Fact: Healthy means the check passed. When the check differs from traffic in port, path, source range, protocol or zone, it passes while traffic fails; a 503 with green backends is that disagreement.

Myth: It works from my laptop, so the service is up.

Fact: Your laptop tests your path, your resolver and your client. Reproduce from the failing vantage point or you are debugging a different system.

Myth: A 503 from the balancer means the backend is overloaded.

Fact: From a proxy, 503 usually means the proxy could not find or reach a usable backend (Envoy UF/UH, HAProxy SC/sQ); read the proxy's own reason before scaling anything.

How pros do it

  • Turn every complaint into one reproduction — URL, client, time, fail versus slow — and check the SLI dashboard for scope before running a single command.
  • Test from the vantage point nearest the failure and run the same command on a host that works; the diff is the finding, and a laptop test is a different system.
  • Use the smallest tool per layer and change one variable per test: --resolve, @server and --http1.1 each swap exactly one thing.
  • Attribute latency with curl -w deltas over three runs before blaming any component; cumulative values are subtracted, not read.
  • Read the balancer's own error reason — nginx error log, Envoy response flags, HAProxy termination state — before touching backends.
  • Treat a stable 1-in-N failure fraction as one bad member or path and isolate by member before changing anything global.
  • Keep a ledger in the incident channel: each command, its result, and what it rules out.

Questions people ask

'The site is slow.' Where do you start?

With a question, not a command: which URL, from where, since when, and does slow mean seconds or timeouts — then the SLI dashboard to split everyone from a subset. Then curl -sv and curl -w from the failing vantage point: curl runs every layer in order and stops at the first broken one, which tells you which single-layer tool comes next. Say out loud that you go bottom-up only when curl cannot even start — no route, no name.

The balancer returns 503 but every backend dashboard is green. What do I look for?

The variable on which the health check and real traffic differ: port, path, source address range, TLS or SNI, zone, or a connection limit the check never reaches. Say you would read the proxy's own error reason first — nginx error log, Envoy response flags, HAProxy termination state — then reproduce the data path from the proxy with curl --resolve toward one backend.

Connection timed out versus connection refused — what does each tell you?

Refused means a RST (or ICMP port-unreachable) came back: the host is reachable and routing works, but nothing is listening on that port or a firewall is rejecting rather than dropping — check ss -tlnp on the target for the bind address and port. Timed out means the SYN got no answer at all: a drop on the path or in a stateless filter, a dead host, or a listener whose accept queue is full — ss -tan shows SYN-SENT on the client, and tcpdump on both ends says whether the SYN ever arrived.

How do I tell real packet loss from an artefact in mtr?

Loss or latency that appears at one hop and vanishes at later hops is that router rate-limiting its ICMP replies; real loss starts at a hop and persists to the destination, so read the last hop first. If a firewall filters ICMP or UDP, match the probe to the traffic with mtr -T -P 443.

What is the single most useful ss invocation?

ss -tan | awk 'NR>1{print $1}' | sort | uniq -c — a histogram of states. Piles of SYN-SENT, CLOSE-WAIT or TIME-WAIT each point at a different owner, and ss -ltn adds the accept-queue depth against its limit. Say which state means whose move it is and you have answered the follow-up too.

When do I reach for tcpdump?

When two hosts disagree and you need proof of who is lying: a capture on the sender shows whether the SYN left, one on the receiver whether it arrived. A SYN present on one side and absent on the other names a filter or route between them; present on both with no SYN-ACK names the listener or its backlog.

How do I keep from fooling myself under pressure?

Change one variable per test, run it from the right vantage point, and write down what each result ruled out before running the next. Anything you have not written down you will end up running twice — and saying that in the room is itself a signal.

Further reading

Drills · 8

Answer in your head, or out loud, before you reveal. Mark each one: "Again" brings it back, "Got it" counts on your desk.

1 Pick the strongest answer

You are paged: an API server listening on :8080 behind an L7 proxy starts failing after a few hours of uptime with accept4: too many open files in its log. On the server, ss -tan state close-wait '( sport = :8080 )' | wc -l returns about 9,000 and climbs steadily, while ss -tan state established | wc -l is a normal ~300. What is happening, and where does the fix live — kernel or application?

  1. These are TIME_WAIT sockets from normal connection churn and are harmless. TIME_WAIT is held by the side that closed first, expires after 60 s and holds no file descriptor; CLOSE-WAIT is the other side, holds an fd, and never expires on its own.
  2. Lower net.ipv4.tcp_fin_timeout so the kernel reaps CLOSE-WAIT sockets sooner. tcp_fin_timeout bounds FIN_WAIT_2 on the side that closed first; CLOSE-WAIT has no timer at all, because the kernel is waiting for the application to call close().
  3. The proxy is leaking connections toward us; raise the server's ulimit -n so the sockets fit. A higher limit only delays the same failure; the sockets are in CLOSE-WAIT because this process owns them and has not closed them, whatever the proxy did.
  4. CLOSE-WAIT is the state of a socket whose peer has sent FIN while the local application has not yet called close(): the proxy closed idle or timed-out connections and the server never closed its end, so each socket still holds a file descriptor. This is an application leak — a handler that returns without closing, or a pool that never reaps peer-closed connections — and the fix is in the code or its idle handling, not in a sysctl. The kernel cannot close a socket on the application's behalf; CLOSE-WAIT accumulates only when our own process ignores EOF, and each one is a live file descriptor.
In short

CLOSE-WAIT means our own process never called close() after the proxy hung up; fix the leak in the application, not a sysctl.

Why

Closing a TCP connection is two half-closes. When the peer sends FIN, our kernel acknowledges it, moves the socket to CLOSE-WAIT, and delivers end-of-file to the application (read() returns 0). The state ends only when the application calls close(), which sends our FIN and moves through LAST-ACK to CLOSED. Nothing in the kernel does that for us, so a growing CLOSE-WAIT count is by definition a file-descriptor leak in our own process — typically a handler that stops reading a connection the proxy has already timed out and closed. Each leaked fd counts against RLIMIT_NOFILE; when the limit is reached, accept() fails with EMFILE and the listener stops serving anyone. Confirm ownership with ss -tanp state close-wait (the PID) and ls /proc/<pid>/fd | wc -l; mitigate with a restart if you must, but the fix is in the code path that ignores EOF.

The common mistake

Reaching for a sysctl — tcp_fin_timeout, tcp_tw_reuse — or raising ulimit -n. No kernel timer clears CLOSE-WAIT; the only thing that does is close() in the application, and a higher fd limit just moves the crash later in the day.

Read the docs

2 Answer out loud

Someone tells you 'the site is slow'. Describe your method — how you decide where to start, which tool you reach for at each layer, and how you avoid fooling yourself — in four to seven sentences, to an interviewer who will follow up on every step you name.

In short

A strong answer makes one reproduction, works down the layers with one tool each from the failing vantage point, changes one variable per test, and writes down what each result rules out.

What a strong answer does
  • scoping: Extracts one concrete reproduction (URL, client location, time, fail versus slow), uses the SLI dashboard to split everyone-versus-subset (shared component versus one path, member or population), and picks the vantage point nearest the failure rather than a laptop.
  • bisection: Smallest tool that isolates one layer, one variable changed per test (--resolve to pin a member, @server to pin a resolver), latency attributed with curl -w deltas over several runs, the balancer's own error reason read before backends are touched, mtr loss at intermediate hops recognised as ICMP rate-limiting, and each result's exclusion written down.
  • communication: States the principle (reproduce, bisect by layer from the right vantage point, one variable per test), then the sequence, then the rule for not fooling yourself, and ends with how they know they are done.
Why

Interviewers score the method, not the tool list: a clarifying question that yields a reproduction, the everyone-versus-subset split, a layer model that says which tool isolates which layer, vantage-point discipline, one variable per test, and a written ledger of exclusions. The senior tells are quantifying with curl -w deltas rather than impressions, reading the balancer's own reason before touching a backend, and knowing that mtr loss at an intermediate hop is not loss. The staff tell is the stopping condition — being able to make the symptom appear and disappear by changing exactly one thing.

The common mistake

Starting to run commands — or restart things — before asking what 'slow' means and for whom. Treating 'the site is slow' as one thing, and testing from your own laptop, are the two fastest ways to lose the room.

Read the docs

3 Scenario: what do you do next?

An internal payments-api runs on six VMs across two zones — 10.0.1.11–13 in zone A, 10.0.2.11–13 in zone B — behind a pool of Envoy edge proxies in 10.0.5.0/24. Envoy health-checks every backend every 10 s, and its health page lists all six hosts healthy. Since 09:40 about half of all requests fail with 503. Every backend dashboard is green: CPU 20%, process up, and the application logs on zone-A VMs show normal traffic while the zone-B VMs have logged nothing since 09:40.

Step 1. You join the incident channel. What is your first move?

  1. Turn on retries for 503 at the Envoy routes so users stop seeing errors. Masks the symptom without a diagnosis, doubles load on the half that works, and you do not yet know whether payments requests are safe to retry.
  2. Fail over to the standby Envoy pool. The proxies are doing exactly what their config and health checks tell them to; a standby with the same configuration and the same backends fails the same way.
  3. Restart the three zone-B VMs; a process that logs nothing must be hung. Their dashboards show a healthy process with no requests arriving, which is the opposite of hung; a restart destroys evidence and, if a filter is the cause, changes nothing.
  4. Read the balancer's own account of the 503s: Envoy's access log response flags and %UPSTREAM_HOST% for the failing requests, grouped by upstream. UF (upstream connection failure), UH (no healthy host) and UT (timeout) are different diagnoses, and whether the 503s come from a specific subset of backends or from the proxy's own decision decides everything that follows. One query on data that already exists splits the hypothesis space — proxy versus backends, all versus some — before anything is changed.

Step 2. Every 503 carries response flags UF and an upstream host in 10.0.2.11–13; requests routed to 10.0.1.x succeed. The health-check log shows GET /healthz on port 8081 succeeding for all six hosts; traffic goes to port 8080. What next?

  1. Raise Envoy's upstream connect timeout so the zone-B connections have more time to establish. A SYN that is dropped never completes; a longer wait turns instant 503s into slow 504s and ties up proxy connections.
  2. Run mtr from your laptop to 10.0.2.11 to check the path. Wrong vantage point and wrong layer: your laptop's ICMP path says nothing about TCP port 8080 from the proxy subnet to that VM.
  3. Repoint the health check at port 8080 right now so Envoy ejects the zone-B hosts. A live config change with no confirmed mechanism; it would also silently halve capacity by ejecting three healthy processes. Fixing the check is right — after you know why 8080 is unreachable, and as a follow-up, not a mitigation.
  4. Reproduce the data path from a proxy host, one variable at a time: curl -sv --resolve payments-api:8080:10.0.2.11 http://payments-api:8080/healthz (does 8080 connect?) then the same against :8081; if 8080 hangs in connect, confirm on 10.0.2.11 with ss -ltn that 8080 is listening and with tcpdump -ni any 'tcp port 8080' whether the SYN ever arrives while you retry. That places the fault on one port between two known hosts. The check passes and traffic fails, so find the variable that differs — the port — and test it from the proxy's vantage point with the smallest tool, confirming on the receiver whether the packet arrives at all.

Step 3. From the proxy, 8080 to 10.0.2.11 hangs in connect while 8081 answers 200; on the VM, ss -ltn shows 8080 listening and tcpdump shows no SYN arriving. A host-firewall policy pushed to zone B at 09:40 admits 8081 from the whole VPC but 8080 only from the old proxy subnet 10.0.0.0/24 — the proxies moved to 10.0.5.0/24 last month. Twenty minutes in. What do you do, and what goes in the postmortem?

  1. Move the proxies back to 10.0.0.0/24 so the existing policy matches them. Undoes a month-old migration to satisfy a stale rule and fixes nothing about a health check that cannot see traffic failing.
  2. Mitigate: add the 8080 allow rule for 10.0.5.0/24 on the three VMs (or roll the policy back), re-run the same curl --resolve, and watch the UF ratio fall to zero. Postmortem mechanisms: health-check the traffic port and path so a check fails whenever traffic would; roll out firewall policy as a canary gated by a synthetic probe from the proxy subnet on the data-plane port; alert on Envoy's per-upstream UF/UH ratio so the next one pages within a minute. Reversible, targeted mitigation with the same test as verification, followed by mechanisms that make the check honest, the change safe, and the detection fast — not reminders.
  3. Open 8080 from 0.0.0.0/0 on the VMs so this can never happen again. Trades a partial outage for an exposure; the rule should name the proxy subnet — the fix is to keep the allow-list correct, not to abolish it.
  4. Ask the security team to be more careful and to check with the network team before pushing policy. A reminder, not a mechanism; the same drift — proxies moved, policy did not — recurs the next time anything moves.
In short

Read Envoy's response flags and upstream host first; the check uses port 8081 but traffic uses 8080, and a firewall rule blocks 8080 from the new proxy subnet.

Why

A 503 with green backends is a disagreement between the health check and real traffic, and the variables it can differ on are few: port, path, source address, protocol or SNI, zone, and connection limits. The interview-preferred sequence reads the balancer's own reason first (response flags plus upstream host), then finds the differing variable (8081 versus 8080), then reproduces the data path from the proxy's vantage point with one variable changed per test, and finally confirms on the receiving host whether the packet arrives at all — ss -ltn proves the listener, tcpdump proves the SYN never reaches it, so the drop is between the hosts. Mitigation is the smallest reversible change verified with the same test, and the postmortem turns the finding into mechanisms: a check that exercises the traffic path, a canaried policy rollout with a data-plane probe, and an alert on the proxy's own failure flags.

The common mistake

Restarting the quiet backends, or flipping the health check to the traffic port as the first move. Both change the system before you know the mechanism, and the second silently ejects three healthy processes; the first move is a query on the log the balancer already writes.

Read the docs

4 Pick the strongest answer

Debug this packet loss for me. Users in one office say app.example.com is slow, and from that office you run mtr --report -c 100 app.example.com. Hop 3 shows 40% packet loss and a latency spike; every later hop — including the final destination — shows 0.0% loss and steady latency. What has this output actually established, and what do you run next?

  1. The loss is an artefact of asymmetric routing: replies from hop 3 take a different return path, so mtr cannot measure that hop. Asymmetric return paths distort the latency attributed to a hop, not whether later hops lose probes — and a genuinely lossy return path would show up in the destination's row too.
  2. Hop 3 is a router that rate-limits or deprioritises the ICMP time-exceeded replies it has to generate; the traffic it merely forwards is unaffected, which is why no later hop shows loss. The path is clean end to end, so the slowness lives elsewhere — DNS, TLS or the server — and the next tool is curl -w timings from that office. Each mtr row is one router answering probes, which is control-plane work routers throttle; real forwarding loss begins at a hop and persists to every hop after it.
  3. Hop 3 is dropping 40% of the office's traffic; open a ticket with the carrier that owns that router. Every probe to hops beyond 3 transits that same router; if it dropped 40% of forwarded packets, every later row would show at least that much loss.
  4. mtr's probes are unreliable by design; rerun with ping -c 100 against hop 3 to get the true loss figure. Pinging the router directly measures the same rate-limited ICMP generation, not what it forwards; the number that matters is the loss at the destination, which is zero.
In short

The path is clean: that hop only slows the ICMP replies it must generate, and the destination shows no loss, so look at DNS, TLS or the server next.

Why

traceroute and mtr send probes with increasing TTLs; each router that decrements a TTL to zero must generate an ICMP time-exceeded message, and generating ICMP is control-plane work that routers rate-limit and deprioritise (RFC 1812 recommends exactly that). A router that is busy or throttled answers some probes and not others, which mtr displays as loss and jitter at that hop while the packets it forwards sail through. Forwarding loss, by contrast, starts at a hop and persists to every later hop, because their probes cross the same router. The reading rule is therefore: look at the last hop first; only loss that reaches the destination is loss your users experience. Here the destination is clean, so the office's slowness is not on the path — the next move is curl -w from that office to attribute it to DNS, TCP, TLS or the server.

Read the docs

5 Read the output

Read me these timings. Where is the 2.5 s being spent — and where is it not — and what is your next step?

# from a bastion inside the VPC; users report the endpoint is "slow"
$ curl -s -o /dev/null -w 'lookup=%{time_namelookup} connect=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer} total=%{time_total} code=%{http_code} ip=%{remote_ip}\n' \
    https://api.example.com/v1/orders/8812
lookup=0.004 connect=0.031 tls=0.078 ttfb=2.514 total=2.531 code=200 ip=203.0.113.10

$ for i in 1 2 3; do curl -s -o /dev/null -w '%{time_connect} %{time_appconnect} %{time_starttransfer}\n' https://api.example.com/v1/orders/8812; done
0.030 0.079 2.488
0.029 0.077 2.602
0.031 0.080 2.531

# one backend behind the balancer, pinned by IP
$ curl -s -o /dev/null -w 'ttfb=%{time_starttransfer} code=%{http_code}\n' --resolve api.example.com:443:10.0.3.14 https://api.example.com/v1/orders/8812
ttfb=0.061 code=200
  1. DNS resolution is slow — the lookup happens first and everything else in the timeline waits on it. time_namelookup is 4 ms; once the connect begins, nothing downstream depends on DNS.
  2. The response body is huge and takes 2.4 s to download; paginate the endpoint. time_starttransfer marks the first byte; the whole body took total − starttransfer = 17 ms. The wait happens before any byte arrives.
  3. TLS is the bottleneck: the handshake takes 78 ms on every request; enable session resumption and the problem is solved. time_appconnect is cumulative from the start; TLS itself took 78 − 31 = 47 ms, and removing all of it would leave 2.45 s untouched.
  4. The time_* values are cumulative, so subtract neighbours: DNS 4 ms, TCP 27 ms, TLS 47 ms — all healthy — and 2.44 s between the request leaving and the first response byte, i.e. on the server side, consistently across three runs. Backend 10.0.3.14 answers the same request in 61 ms when pinned with --resolve, so the wait is not in that backend's code. Next: pin each remaining backend in turn and read the balancer's per-upstream response time, to learn whether one slow member or the balancer itself owns the 2.4 s. curl's timings attribute latency layer by layer once you subtract; the --resolve run changes exactly one variable — which host answers — and shows the slowness is not universal to the backends.
In short

Subtract the cumulative timings: DNS, TCP and TLS are fast and 2.4 s is spent waiting for the server; pin each backend in turn to find the slow one.

Why

curl -w exposes the same timeline -v narrates, as numbers: time_namelookup ends DNS, time_connect ends the TCP handshake (one RTT — 27 ms here), time_appconnect ends TLS (one RTT on TLS 1.3 plus certificate work — 47 ms), time_starttransfer is the first response byte, and time_total the last. The deltas attribute latency to layers; the raw values do not. Three consistent runs rule out a transient. --resolve host:port:IP then changes one variable — which host answers — while keeping the Host header, SNI and certificate verification honest, and the pinned backend answering in 61 ms proves the code path is fast on at least one member. What the output does not prove is that the balancer is at fault: another member may be slow, or the balancer's chosen route or its own queue may be. The next step is therefore the same test against each other member plus the balancer's per-upstream response times, not a change to anything.

Read the docs

6 Pick the strongest answer

A JSON-RPC pool of 12 full nodes sits behind a round-robin L7 balancer. A dApp team reports that eth_blockNumber sometimes returns a height from a minute ago and that their retries eventually succeed. Your synthetic probe over ten minutes shows a stable 1-in-12 rate of stale answers — never 2-in-12, never zero. The balancer's health page shows all 12 nodes healthy and the pool's aggregate p99 is normal. What does the stable fraction tell you before you run anything, and which move isolates the fault fastest?

  1. Raise the balancer's health-check frequency so the lagging node is detected sooner. The check passes on a node that is lagging; asking the wrong question more often does not change the answer — and you still have not identified the node.
  2. The stale reads are the dApp's client-side cache; a 1-in-12 rate on a 12-node pool is coincidence. Random client caching does not produce a fraction that matches the pool size and holds for ten minutes; a stable 1/N is the signature of an even balancer with one bad member.
  3. A failure fraction that sits at exactly 1/N behind an even balancer is one bad member, not a systemic fault: the balancer is spreading requests evenly and one of them is wrong every time it is chosen. Take the balancer out of the loop and change only which member answers — curl --resolve rpc.example.com:443:<node-ip> against each node in turn, comparing heights, or group the probe's failures by the upstream identifier the balancer logs — then drain the lagging node and fix the health check to measure head lag. The fraction is diagnostic before any command; isolating by member with one variable changed is the fastest route to a name, and draining is the reversible mitigation.
  4. Enable retries at the balancer so a stale answer is retried on another node. A stale height is a 200 with wrong data; nothing fails, so nothing is retried — and if it were, retries would hide the bad member instead of finding it.
In short

A stable 1-in-N failure rate means one bad node; pin each node with curl --resolve, compare answers, then drain the lagging one.

Why

Behind an even balancer, one bad member out of N produces a failure fraction of 1/N of requests at random — two bad members give 2/N, one bad ECMP path gives 1/N of flows — so a stable round fraction is a fingerprint you can read before running a command. The isolation move changes exactly one variable, which member answers: --resolve keeps the hostname, SNI and certificate honest while pinning the IP, and comparing each node's answer against the others names the laggard in N requests. The balancer's access log gives the same answer faster if it records the upstream host per request — correlate the probe's stale responses with that field. Mitigation is draining the node; the durable fix is a health check that fails on head-lag relative to peers, because a check that only proves the process is alive cannot see a node that is alive and wrong. The chain-data setting is incidental: a read replica behind a database proxy fails the same way.

Read the docs

7 Quick recall

You want to hit one pool member directly while the Host header, SNI and certificate verification stay honest. Which curl option?

In short

Use curl --resolve host:port:IP (or --connect-to).

Accepted

--resolve · resolve · curl --resolve

Why

--resolve host:port:IP preloads curl's DNS cache so the request goes to the chosen address while the URL, Host header, SNI and certificate check stay honest; --connect-to host:port:otherhost:otherport does the same by hostname and can change the port. Both are how you bisect a pool member by member without editing /etc/hosts.

Read the docs

8 Find what's broken

The app process on api-1 crashed an hour ago, yet the stats page shows api-1 and api-2 UP (api-3 shows no check) and about a third of requests fail with 503 and termination state SC-- after roughly three seconds. At the afternoon peak a second cluster of 503s appears after exactly 5 s with state sQ--. Port 9102 is the metrics exporter sidecar that runs on every VM. Which lines are responsible, and what do you change?

global
    log stdout format raw local0
    maxconn 20000

defaults
    mode http
    log global
    option httplog
    timeout connect 5s
    timeout client 30s
    timeout server 30s

frontend fe_api
    bind *:443 ssl crt /etc/haproxy/certs/api.pem alpn h2,http/1.1
    default_backend be_api

backend be_api
    balance roundrobin
    option httpchk
    http-check send meth GET uri /healthz hdr Host api.internal
    http-check expect status 200
    default-server inter 5s fall 3 rise 2 port 9102
    server api-1 10.0.3.11:8080 check
    server api-2 10.0.3.12:8080 check maxconn 20
    server api-3 10.0.3.13:8080
In short

Lines 22, 24 and 25: check the traffic port instead of the exporter port, size or remove maxconn 20, and add check to api-3.

What's broken
  • Line 22: port 9102 on default-server sends every health check to the exporter sidecar, so the check passes as long as the sidecar answers — including on api-1, whose application on 8080 is dead. The check exercises a different path than traffic.
  • Line 24: maxconn 20 caps api-2 at 20 concurrent connections; above that, requests queue in the backend and, after timeout queue (unset, so it inherits timeout connect = 5 s), HAProxy returns 503.
  • Line 25: server api-3 has no check, so HAProxy never health-checks it and always treats it as available; when its application dies it keeps receiving its full share of traffic.
Why

HAProxy returns 503 for three different reasons that look identical to a user and different in the log's termination state: SC means it chose a server and the connection was refused or unreachable — here a dead server still marked UP because the check aimed at a different port, and with the default retries 3 and a one-second turn-around between attempts the 503 arrives about three seconds in (instantly only with retries 0); sQ means the request waited in the backend queue for timeout queue because every eligible server was at its maxconn; and "no server is available" means every server is DOWN. A health check must exercise the port and path traffic uses, and a server must actually carry check to be checked at all. The distractors are sound: global maxconn 20000 (line 3) is a process-wide connection cap; timeout connect 5s (line 9) is reasonable, though worth knowing it doubles as the default queue timeout; and the http-check send line (line 20) is correct current syntax for a checked path with a Host header.

Read the docs

Next lesson Routing in the cloud: CIDR, route tables, NAT, security groups vs NACLs, peering, BGP/anycast, MTU
Drill · Network troubleshooting
0:00

Loading…