Network latency and jitter directly impact application performance, especially for real-time services, databases, and user-facing web applications. This guide covers systematic approaches to identifying and resolving latency issues.
Measuring Latency
# Basic ping test
ping -c 100 destination-server
# Look at: min/avg/max/mdev (standard deviation = jitter)
# ping with timestamps
ping -D -c 50 destination-server
# hping3 for TCP-based latency testing (bypasses ICMP filters)
sudo apt install hping3
sudo hping3 -S -p 443 destination-server -c 20Measuring Jitter
# Jitter = variation in latency over time
# High jitter causes: choppy VoIP, inconsistent page loads, database timeouts
# From ping output:
ping -c 100 destination-server
# mdev = standard deviation ≈ jitter
# Good: mdev < 5ms
# Acceptable: mdev 5-20ms
# Bad: mdev > 20ms
# Using mtr for detailed jitter analysis
mtr -r -c 100 destination-server
# StDev column shows jitter at each hopIdentifying Latency Sources
# Use MTR to find which hop introduces latency
mtr -r -c 100 destination-server
# Look for:
# 1. Sudden latency increase at a specific hop
# 2. High StDev at a specific hop
# 3. Packet loss starting at a specific hop
# Common latency sources:
# - Geographic distance (10-15ms per 1000 miles)
# - Congested network links
# - Overloaded servers
# - DNS resolution delays
# - TLS handshake overheadApplication-Level Latency
# Measure HTTP response time
curl -o /dev/null -s -w "DNS: %{time_namelookup}s\nConnect: %{time_connect}s\nTLS: %{time_appconnect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n" https://example.com
# Breakdown:
# DNS lookup: Time to resolve the hostname
# TCP connect: Time to establish TCP connection
# TLS handshake: Time for SSL/TLS negotiation
# TTFB: Time to first byte (server processing)
# Total: Complete request timeReducing Latency
# 1. Use a CDN (Cloudflare, etc.)
# Reduces latency for static content from 100ms to