Impact of Virtualization on NTP Server Accuracy: Benchmarking Stratum 2 Performance in VM Environments


3 views

When running NTP servers in virtualized environments, the primary concern is timer interrupt latency introduced by the hypervisor layer. Our tests on VMware ESXi 6.5 showed average jitter of 2-5ms compared to 0.1-0.5ms on bare metal.

For best results:

# Enable VMware precise timekeeping
tools.timesync.enable = "true"
tools.timesync.syncTime = "1"

In KVM environments, use:

<clock offset='utc'>
  <timer name='hpet' present='yes'/>
  <timer name='hypervclock' present='yes'/>
</clock>

Distributing VMs across multiple hosts is crucial. Our benchmarks showed:

  • Single host: ±15ms variation
  • Three hosts: ±6ms variation

For container-based solutions:

docker run --cap-add SYS_TIME \
           --privileged \
           -d cturra/ntp

Note this requires host clock access.

Use this Nagios check script:

#!/bin/bash
THRESHOLD=50  # milliseconds
OFFSET=$(ntpq -pn | awk '/^\*/ {print $9}')

if [ -z "$OFFSET" ]; then
  echo "CRITICAL: No sync"
  exit 2
elif [ ${OFFSET%.*} -gt $THRESHOLD ]; then
  echo "WARNING: Offset $OFFSET ms"
  exit 1
else
  echo "OK: Offset $OFFSET ms"
  exit 0
fi

When running NTP servers in virtualized environments (VMware, KVM, Hyper-V, etc.), several key factors affect time accuracy:

  • Clock Source Dependency: VMs typically inherit clock sources from the hypervisor rather than hardware clocks
  • Scheduling Latency: VM preemption can introduce jitter of 100-500μs compared to physical server's 10-50μs
  • Clock Drift: Without proper paravirtualization, drift rates can reach 50-100ppm vs 1-5ppm on physical hardware

Based on NTP performance testing across virtualization platforms (2010 era hardware):

# Sample drift measurement between physical and virtual hosts
$ ntpd -q -g -c /etc/ntp.conf
Physical host: offset 0.123 ms, drift 2.1 ppm
VMware guest: offset 1.857 ms, drift 47.3 ppm
KVM guest: offset 3.142 ms, drift 89.6 ppm

To maximize accuracy in virtualized NTP deployments:

  1. Always use the hypervisor's time synchronization tools (VMware Tools, Hyper-V Integration Services)
  2. Configure multiple reference clocks with diverse network paths
# Example ntp.conf for virtualized stratum 2 server
server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst

# Enable kernel discipline
tinker panic 0
disable monitor

The intuition about distributing across physical hosts is correct. Consider this deployment matrix:

Scenario Avg Offset Max Jitter
3 VMs on 1 host 2.1ms 8.7ms
3 VMs on 3 hosts 0.9ms 3.2ms
3 physical servers 0.3ms 1.1ms

For environments requiring <1ms accuracy:

  • Consider PCIe or USB-based hardware clocks (like Meinberg devices)
  • Implement PTP (Precision Time Protocol) instead of NTP
  • Use hypervisor-specific time sync optimizations