Measuring NTP (QPS)


#1

I joined the pool yesterday and then early this morning I apparently crossed the barrier (above 10)
Your Servers
Current score: 18.7
Stratum: 2

So I can be used in the pool, … I went and looked at the traffic running by using wireshark… it looks like a LOT, but I would like to know exactly how A LOT… So, how do most of you get your exact or close to exact numbers of QPS?


#2

If you are running the standard NTP distribution, you can use ‘ntpdc -c iostats’ and it will show you relevant info which can be parsed in to your logging program of choice. Be mindful if you restart ntp those numbers will reset so your script should take that into account.

Also if you are running linux, be sure to add something like the following lines to your iptables so that you don’t waste a ton of slots on pointless connection tracking.

iptables -t raw -A PREROUTING -p udp --dport 123 -j NOTRACK
iptables -t raw -A OUTPUT -p udp --sport 123 -j NOTRACK


#3

This works on CentOS:

#!/bin/sh

delay=60
prevrec=0
prevsent=0
while true
do
	read received sent <<< $( ntpdc -c iostats | grep -e "received packets" -e "packets sent" | awk '{ print $3 }' )
	echo $[ ($received-$prevrec)/$delay ] queries per second, $[ ($sent-$prevsent)/$delay ] responses per second
	prevrec=$received
	prevsent=$sent
	sleep $delay
done | tail -n +2

#4

Hopefully you’re running not such an old version of ntpd that ntpdc works, so you would use ‘ntpq -c iostats’.

Also, if you use munin, which I highly recommend, I wrote a plugin which graphs packet counts: https://github.com/munin-monitoring/contrib/blob/master/plugins/ntp/ntp_packets

There are several other ntp plugins for munin, both in the standard distribution and the contrib repository.


#5

My recommendation is collectd with the iptables plugin. It’s very lightweight and can collect data every second.

If you had the following rules in iptables:

-A INPUT -p udp -m udp --dport 123 -m comment --comment ntp_ipv4_in -j ACCEPT
-A OUTPUT -p udp -m udp --sport 123 -m comment --comment ntp_ipv4_out -j ACCEPT

in collectd.conf they would be selected like this:

<Plugin iptables>
  Chain "filter" "INPUT" "ntp_ipv4_in"
  Chain "filter" "OUTPUT" "ntp_ipv4_out"
</Plugin>

#6

YES, the command you gave me worked, apparently like you suspected the previous command was for older versions and as a result did not function in my system… below is the output…
Thanks.
Question… how much TIME does this represent?: time since reset: 10755
If its seconds, that means I’m fulfilling about 230 time requests per second… which doesnt seem like a lot compared to some of the numbers I have been hearing people claim like between 10 and 50 thousand per second!

C:\Windows\System32>ntpq -c iostats
time since reset: 10755
receive buffers: 34
free receive buffers: 13
used receive buffers: 0
low water refills: 5
dropped packets: 0
ignored packets: 0
received packets: 2467255
packets sent: 2467310
packet send failures: 0
input wakeups: 4935253
useful input wakeups: 2467255


#7

Yes, I believe it is in seconds. QPS will depend on what zone you are in and what you have the bandwidth setting to on the Pool webpage. For the ones with 10k+ QPS those are probably people in the China zone.

For instance, my server is in the US pool, 100 Mb, and I see on average ~300 QPS. Though there have been short spikes of over 1,000 QPS every few days.


#8

Ok, well it would seem I’m pretty much where I should be, I’m set to 100 also and in the US…the only other thing I want to do is evetually find a halfway decent (well, $100 or less decent) GPS solution so I dont have to depend on another NTP server or find someone who wants to “volunteer” to build me a rasp-pi solution… I would of course buy the parts and pay like a small labor fee… the pool should go into the rasp-pi NTP server building business, they might attract more “poolers” that way?