What is Latency?
Latency is the time delay between initiating a request and receiving a response, typically measured in milliseconds (ms). In networking and DNS contexts, latency represents the round-trip time for data to travel from a client to a server and back. Low latency is critical for fast website loading, responsive applications, and positive user experiences. High latency causes noticeable delays that frustrate users and can impact business metrics.Types of Latency
Network Latency
Time for data packets to traverse the network:
- Physical distance between client and server
- Number of network hops (routers, switches)
- Network congestion and bandwidth limitations
- Quality of network infrastructure
DNS Latency
Time to resolve a domain name to an IP address:
- DNS server response time
- Cache status (hit vs miss)
- DNS query chain (resolver → authoritative)
- DNSSEC validation overhead
Application Latency
Time for applications to process requests:
- Database query execution
- Server-side processing
- API response generation
- Backend service communication
Measuring Latency
Common Tools
# Ping test (ICMP latency)
ping example.com
# DNS resolution time
dig example.com | grep "Query time"
# HTTP timing
curl -w "@curl-format.txt" -o /dev/null -s https://example.com
Key Metrics
| Metric | Description | Good Target |
|---|---|---|
| RTT (Round Trip Time) | Complete request-response cycle | <100ms |
| TTFB (Time to First Byte) | Server response initiation | <200ms |
| DNS Resolution | Domain to IP lookup | <50ms |
| Connection Time | TCP handshake completion | <100ms |
Latency Impact by Region
Geographic distance directly affects latency:
| Route | Typical Latency |
|---|---|
| Same city | 1-10ms |
| Same country | 20-50ms |
| Same continent | 50-100ms |
| Cross-continental | 100-200ms |
| Global (opposite sides) | 200-300ms |
Reducing DNS Latency
Anycast DNS
Deploy DNS servers globally, route queries to nearest:
- Multiple servers share same IP address
- Automatic routing to closest location
- Built-in redundancy
DNS Caching
Leverage TTL for repeated lookups:
example.com. 300 IN A 192.0.2.1
↑ TTL in seconds
- Browser cache (seconds to minutes)
- Operating system cache
- ISP resolver cache
EDNS Client Subnet
Enable geographically-aware responses:
- Client location passed to authoritative server
- Return closest server IP
- Improved CDN performance
Reducing Overall Latency
Content Delivery Networks (CDNs)
- Cache content at edge locations
- Serve users from nearby servers
- Reduce origin server load
Connection Optimization
- HTTP/2 multiplexing
- Keep-alive connections
- TLS session resumption
- HTTP/3 (QUIC) for reduced handshakes
Infrastructure Choices
- Multiple data center locations
- Premium network providers
- Optimized routing paths
- Edge computing for dynamic content
Latency vs Bandwidth
Understanding the difference:
- Latency: How fast data starts arriving (delay)
- Bandwidth: How much data can flow per second (throughput)
Both matter for performance, but latency often has greater impact on user-perceived speed, especially for interactive applications.
Low latency is essential for modern web performance, directly impacting user satisfaction, conversion rates, and search engine rankings.