发现 aliyun 的 ntp 不够准确啊

2017-09-30 11:07:23 +08:00
 mengzhuo

因为楼主自己有写了 ntp 服务,顺带跑 ntp 集群,国内的就近使用了 aliyun 的公共服务,结果发现在 ntp.org 上总是有 50ms 左右的误差。

一开始怀疑的是自己写的代码有问题,但其他节点都在 10ms 以下的精度了,所以就怀疑到了 aliyun 本身的时钟误差,然后发现果然慢了 20ms 左右。

所以大家可以抛弃 aliyun 的 ntp,换 Google 或者 Apple 的都比 aliyun 准确

下面是跑脚本 3 次的结果,代码我附在最后

time2.aliyun.com,28.655746ms
time3.aliyun.com,26.759582ms
time5.aliyun.com,29.008967ms
time6.aliyun.com,22.483205ms
time1.google.com,302.125µs
time2.google.com,154.277µs
time3.google.com,942.302µs
time1.apple.com,128.849µs
time2.apple.com,150.666µs
time3.apple.com,46.247µs
time4.apple.com,263.644µs
time5.apple.com,196.309µs
time6.apple.com,28.467µs
time3.aliyun.com,25.598556ms
time5.aliyun.com,29.037168ms
time6.aliyun.com,14.518584ms
time1.google.com,0s
time2.google.com,1.146204ms
time2.apple.com,0s
time3.apple.com,0s
time4.apple.com,0s
time6.apple.com,0s
time1.aliyun.com,14.320869ms
time2.aliyun.com,26.738995ms
time3.aliyun.com,26.47347ms
time4.aliyun.com,26.599685ms
time5.aliyun.com,28.720771ms
time1.google.com,66.609µs
time2.google.com,129.603µs
time3.google.com,438.115µs
time1.apple.com,-91.208µs
time2.apple.com,121.155µs
time3.apple.com,-142.25µs
time4.apple.com,61.033µs
time5.apple.com,81.492µs
time6.apple.com,-171.77µs

https://gist.github.com/mengzhuo/8acbd88b71d0a88c6844a22f0f39093f

14888 次点击
所在节点    云计算
43 条回复
refactor
2017-10-03 22:43:47 +08:00
@lolizeppelin 是的,ntp FAQ 里面说得很清楚:

http://www.ntp.org/ntpfaq/NTP-s-algo.htm

Of course the final achievable accuracy depends on the time source being used. Basically, no client can be more accurate than its server. In addition the quality of network connection also influences the final accuracy. Slow and non predictable networks with varying delays are very bad for good time synchronization.

A time difference of less than 128ms between server and client is required to maintain NTP synchronization. The typical accuracy on the Internet ranges from about 5ms to 100ms, possibly varying with network delays. A recent survey[2] suggests that 90% of the NTP servers have network delays below 100ms, and about 99% are synchronized within one second to the synchronization peer.

With PPS synchronization an accuracy of 50µs and a stability below 0.1 PPM is achievable on a Pentium PC (running Linux for example). However, there are some hardware facts to consider. Judah Levine wrote:
stockmaster
2020-05-25 02:23:31 +08:00
请问 cn.ntp.org.cn 精度怎么样?和阿里云比?
mengzhuo
2020-05-25 13:35:59 +08:00
@stockmaster 差 50ms 左右,主要服务器大部分是志愿者维护的,很多服务还是国外的。不过 cn pool 里有阿里和腾讯的 ntp 服务器,一般用 ntpd 或者 chrony 这类都会自动选到的。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://tanronggui.xyz/t/394813

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX