← All guides

Check Network Latency Between Servers: ping & traceroute

Updated:

Check Network Latency Between Servers: ping & traceroute

Monitor network latency between servers to track network performance, detect connectivity issues, and optimize network configuration. This guide shows you how to check latency and set up automated monitoring.

For comprehensive network monitoring, see Network Health Monitoring. For troubleshooting network issues, see Network Connectivity Issues.

Why Checking Network Latency Matters

Network latency directly impacts application performance, especially for distributed systems and database connections. High latency causes slow response times and poor user experience. Monitoring latency helps maintain optimal network performance.

Method 1: Check Latency with ping

Measure Latency with ping

# Basic latency check
ping -c 10 server.example.com

# Get average latency
ping -c 10 server.example.com | grep "avg" | awk -F'/' '{print $5}'

# Check latency to multiple servers
for server in server1.example.com server2.example.com server3.example.com; do
  echo -n "$server: "
  ping -c 5 $server | grep "avg" | awk -F'/' '{print $5 "ms"}'
done

Monitor Latency Over Time

# Monitor latency continuously
while true; do
  LATENCY=$(ping -c 1 server.example.com | grep "time=" | awk -F'time=' '{print $2}' | awk '{print $1}')
  echo "$(date): $LATENCY ms"
  sleep 60
done

Method 2: Check Latency with traceroute

Analyze Network Path Latency

# Trace network path
traceroute server.example.com

# Get latency per hop
traceroute -n server.example.com | awk '{print $1, $3}'

# Check latency to specific hop
traceroute server.example.com | grep " 5 "

Method 3: Automated Latency Monitoring with Zuzia.app

Checking by hand tells you the state right now. Zuzia checks from outside, around the clock, with nothing installed on the server.

How it works in Zuzia

  • Add a URL, a TCP port or a DNS record with the value you expect. The first check runs within about 30 seconds.
  • Websites can be checked as often as once a minute, from agents in Poland, New York and Singapore. Zuzia records the HTTP status code and response time of every check.
  • Zuzia warns you 14, 7 and 3 days before an SSL certificate expires, and does the same for the domain registration.
  • Alerts go by email, Slack, Discord, push (through your Pushover account) or SMS (through your Vonage account). A public status page or an embeddable widget shows your client the same uptime you see.

Setting it up

  1. In the Zuzia dashboard, add the URL, port or DNS record.
  2. Choose the check interval and your notification channels.
  3. Optionally create a status page or a widget for the client.

For the checks in this guide that run on the server itself, install the Zuzia agent and save those commands as a scheduled task.

Best Practices for Latency Monitoring

1. Monitor Latency Continuously

  • Track latency regularly
  • Alert when latency exceeds thresholds
  • Monitor latency trends over time
  • Optimize network configuration based on data

2. Monitor Multiple Network Paths

  • Test latency to different servers
  • Monitor latency across network segments
  • Compare latency from different locations
  • Identify network bottlenecks

3. Set Appropriate Thresholds

  • Set thresholds based on application requirements
  • Adjust thresholds for different server types
  • Monitor latency percentiles
  • Alert on latency degradation

4. Correlate Latency with Other Metrics

  • Compare latency with network bandwidth
  • Correlate with application performance
  • Monitor latency during peak traffic
  • Identify performance bottlenecks

Troubleshooting Latency Issues

Step 1: Identify Latency Problems

When latency is high:

# Check current latency
ping -c 10 server.example.com

# Test latency to multiple servers
for server in server1 server2 server3; do
  ping -c 5 $server | grep "avg"
done

# Check network path
traceroute server.example.com

Step 2: Optimize Network Performance

Based on investigation:

  1. Optimize Network Configuration:

    • Tune network settings
    • Optimize routing
    • Reduce network hops
  2. Fix Network Issues:

    • Resolve network connectivity problems
    • Fix network configuration errors
    • Update network infrastructure
  3. Scale Network Infrastructure:

    • Add network capacity if needed
    • Implement network optimization
    • Upgrade network equipment

FAQ: Common Questions About Latency Monitoring

What is considered high network latency?

High latency depends on your application requirements. Generally, latency under 10ms is excellent for local networks, 10-50ms is good, 50-100ms is acceptable, and over 100ms is high. Set thresholds based on your requirements.

How often should I check network latency?

For production servers, continuous automated monitoring is essential. Zuzia.app can check latency every few minutes, storing historical data and alerting you when latency exceeds thresholds.

How do I improve network latency?

Improve network latency by optimizing network configuration, reducing network hops, using faster network connections, optimizing routing, and fixing network connectivity issues.

Can latency monitoring impact network performance?

Latency monitoring commands have minimal impact on network performance when done correctly. Use appropriate monitoring frequency and avoid excessive pings during monitoring.

Related guides, recipes, and problems

  • Related guides

    • guides--monitoring-network-bandwidth-linux.md
    • guides--network-health-monitoring-server-management.md
  • Related recipes

    • recipes--monitor-network-connections-linux.md
    • recipes--monitor-network-errors-dropped-packets.md
  • Related problems

    • problems--network-connectivity-issues-linux.md
    • problems--server-slow-performance-issues.md

We use cookies to ensure the proper functioning of our website.