测量使用广播系统时钟的消息延迟,好主意吗? [英] Measuring broadcast message latency using system clock, good idea?

查看:274
本文介绍了测量使用广播系统时钟的消息延迟,好主意吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要测量超过1GB的LAN上我们的消息代理广播消息的延迟。

I want to measure broadcast message latency over our message broker on a 1GB LAN.

消息被一家酒吧分时尚,一个发布,很多消费者传播。生产者时间戳使用系统时钟(DateTime.Now在C#),每封邮件和消费者衡量减去从DateTime.Now消息时间戳延迟。

Messages are transmitted in a pub sub fashion, one publisher, many consumers. The producer timestamps each message using the system clock (DateTime.Now in C#) and consumers measure latency by subtracting the timestamp on the message from DateTime.Now.

 double latency = (DateTime.Now - msg.NMSTimestamp).TotalMilliseconds;



我们所有的LAN上的箱子通过NTP同步他们的时间还早一小时一次我看到显著延迟甚至负的时间在+/- 1秒范围内。我读了NTP应提供在局域网环境中〜5ms的准确性。

All of the boxes on our LAN sync their time via NTP once an hour yet I'm seeing significant latency and even negative times in the range of +/- 1 second. I read that NTP should provide ~5ms accuracy in a LAN environment.

是我的测量策略根本性的缺陷?是否有负延迟另一种解释?如果我只是看到大量的等待时间我怀疑我们的消息队列是缓慢的,但消极因素确实有我糊涂了。

Is my measurement strategy fundamentally flawed? Is there another explanation for the negative latency? If I was only seeing large latencies I'd suspect our message queue was slow but the negative ones really have me confused.

推荐答案

什么是你看起来像在米利斯负值?如果它的5毫秒之内,这是正常的,NTP,你也知道。甚至有可能是计算机之间长达10米利斯区别,如果一台计算机是超越真实时间5毫秒时间,另一个是5落后。更重要的是,我猜某处有一个在你的系统中的一些舍入误差,超前/后向错误或同步错误。有你有过那么一点的控制可以产生很多不准确的硬件和实施细则。通常情况下,当DateTime.Now调查,但许多硬件细节,比如加载,管道,高速缓存抖动等下CPU节流可以引入足够的误差是毫秒级显著系统时钟是毫秒级不够准确。

What are your negative values looking like in millis? If it's within 5ms, that's normal for NTP, as you know. There could even be up to 10 millis difference between computers if one computer was 5 millis ahead of true time and another was 5 behind. More than that, I would guess that there's some rounding error, lookahead/lookbehind error, or sync errors somewhere in your system. There are many hardware and implementation details you have little control over that can produce inaccuracies. GENERALLY, system clocks are accurate enough at the millisecond level when polled by DateTime.Now, but many hardware details like CPU throttling under load, pipelines, cache thrashing etc. can introduce enough error to be significant at the millisecond level.

如果可能,请设置您的计算机与NTP服务器至少第二分开形成相互同步。如果所有的电脑上试小时每隔一小时同步,NTP服务器将被淹没,在报告正确的时间由于拥挤和分组调度增加的不准确。我觉得这是发生了什么事情最可能的原因。此外,请确保您的网络尽可能高效,减少电缆运行(300英尺是理论上的最大值,并在EMI-嘈杂的环境中运行短40英尺可能会导致严重的问题),带开关代替集线器,并尽量减少无线网络使用。

If possible, set up your computers to synchronize with the NTP server at least a second apart form each other. If all computers try to sync on the hour every hour, the NTP server will be flooded, increasing inaccuracies in reporting the correct time due to crowding and packet scheduling. I think this is the most likely cause for what's going on. Also, make sure your network is as efficient as possible, by reducing cable runs (300ft is the theoretical maximum, and in an EMI-noisy environment runs as short as 40 feet can cause serious problems), replacing hubs with switches, and minimizing wireless network use.

这篇关于测量使用广播系统时钟的消息延迟,好主意吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆