Clarify scope & goal
- Confirm affected region, time windows, percent of requests (5%), and exact user paths/endpoints. Goal: determine whether cause is network routing, CDN, load balancer (LB), or backend.
1) Collect baseline metrics
- Check SLOs, median/p95/p99 latencies from monitoring (Prometheus/Grafana, CloudWatch).
- Correlate by region, POP, endpoint, and backend instance IDs.
2) Traces & distributed tracing
- Pull traces for slow requests (Jaeger/NewRelic/Datadog). Look for where time is spent: client→edge, edge→origin, LB→backend, DB.
- If traces show long edge→client time → suspect network/CDN. If long backend spans → app.
3) Network-level tests (from affected region)
- Run traceroute/MTR to edge and origin to spot routing loops or packet loss:
bash
mtr -c 100 -r -w <edge-ip-or-hostname>
traceroute -I <edge-ip-or-hostname>
- Test TCP connect and handshake latency:
bash
tcptraceroute <host> 443
curl -w "@curl-format.txt" -o /dev/null -s "https://host/path"
# curl-format.txt example: time_namelookup: %{time_namelookup}\n...
- Use pings and packet capture:
bash
ping -c 50 <edge-ip>
sudo tcpdump -i eth0 host <edge-ip> and port 443 -w capture.pcap
- Interpretation: high initial RTT or packet loss => routing/ISP.
4) CDN checks
- Validate CDN edge behavior: request with and without CDN bypass, inspect response headers (cache-status, Via):
bash
curl -I -H "Host: example.com" https://cdn.example.com/path
curl -I --resolve example.com:443:<origin-ip> https://example.com/path
- Compare headers and times; use CDN logs/edge metrics for spikes. If origin is fine but edge shows delay → CDN issue or POP saturation.
5) Load balancer checks
- Check LB metrics: active connections, request queue length, target health, per-AZ distribution.
- Query LB logs (ELB/ALB/Nginx): look for 5xx, target response times.
- Reproduce with direct-to-backend bypassing LB (if safe) using --resolve to map DNS to a backend IP and compare latencies.
6) Backend application checks
- Correlate slow traces to backend spans (DB calls, GC, thread starvation).
- Check server metrics during incidents: cpu, iowait, load, disk, network:
bash
top -b -n1
iostat -xz 1 3
sar -n DEV 1 3
ss -tna | wc -l
- Review application logs for timeouts, slow queries. Capture flamegraphs or profiling if necessary.
7) Narrow with synthetic tests and canary probes
- From multiple vantage points (affected region and control regions) run synthetic curl loops, mtr, and APM-injected traces to compare:
bash
for i in {1..100}; do curl -s -w '%{time_total}\n' -o /dev/null https://example.com/path; done
- Run tests at varying times to align with observed spikes.
8) Packet-level for root cause
- If network suspected, compare captures from client-side and edge to find where latency adds (SYN->SYN/ACK delay, retransmits).
- Use Wireshark/tshark to inspect:
bash
tshark -r capture.pcap -q -z io,phs
9) Hypotheses & quick fixes
- If CDN POP saturated → route traffic to healthier POPs or increase capacity; enable cache TTL tuning.
- If LB queueing → scale targets, adjust deregistration/draining, or change LB timeouts.
- If backend → scale, fix DB queries, increase connection pool, or patch slow code.
10) Document and escalate
- Produce timeline, correlated graphs (latency vs packet loss vs errors), and trace examples. If issue is ISP or CDN provider, open ticket with packet captures, traceroutes, and timestamps.
This plan ties metrics, logs, and traces to concrete tests/commands so you can isolate whether delays occur on the network path, CDN edge, LB layer, or backend service.