简体   繁体   English

算法-跟踪从一项服务到另一项服务的数据延迟

[英]Algorithms - Tracking latency of data from one service to another

Say I subscribe to a service that gives me the temperature in my city and it sends data ticks sometimes really fast, sometimes in longer intervals. 假设我订阅了一项服务,该服务为我提供了我所在城市的温度,并且它有时会很快,有时间隔较长地发送数据更新。

Temp Timestamp (ms)
20C 1
21C 2
20C 286
21C 287
21C 288
21C 289
20C 423
etc.

Now lets say the subscriber service converts to Fahrenheit and republishes this data within my company, with it's own timestamp of when it does so. 现在,可以说订户服务转换为华氏度,并在我公司内部重新发布此数据,并带有自己的时间戳。

Caveat 1: Some ticks of data are dropped because some of the ticks come in faster than can be recalculated to Fahrenheit, so it will take the latest value in the Queue. 注意事项1:删除了一些滴答数据,因为某些滴答输入的速度快于可以重新计算为华氏度的速度,因此它将采用队列中的最新值。

Caveat 2: The Fahrenheit data published may take "longer" (ie. have higher latency) if a lot of ticks come in reducing available bandwidth. 注意事项2:如果在降低可用带宽方面有很多of滴,那么发布的华氏数据可能会花费更长的时间(即具有更高的延迟)。

Temp Timestamp (ms)
68F 2:00:00:0001
69F 2:00:00:0023
68F 2:00:00:0063
etc..

What would be the best way to "match" the possible corresponding ticks and calculate a latency between the two services? “匹配”可能的相应报价并计算两个服务之间的延迟的最佳方法是什么? Would it be better to report two latencies? 报告两个延迟会更好吗? One during high load and one during standard load? 在高负荷下是一只,在标准负荷下是一只? If so, how do I determine when high load is? 如果是这样,我如何确定什么时候是高负载? When some latency values are certain std deviations away? 什么时候某些延迟值会偏离某些std?

You have a Celsius service C, a Fahrenheit service F, and a Fahrenheit subscriber S. 您有摄氏服务C,华氏服务F和华氏订户S。

There are three places you can measure latency: 您可以在三个地方测量延迟:

C--->F (The time it takes for outbound C to go to F)
F--->S (The time it takes for outbound F to go to S)
F(c)   (The time of computation for Celsius to Fahrenheit).

If you timestamp all outbound traffic, whether outbound of C or F, you can measure service latency from the consumer's perspective simply by comparing the timestamp to the current time and getting the latency. 如果为所有出站流量加上时间戳,无论是C还是F的出站,都可以通过简单地将时间戳与当前时间进行比较并获得延迟来从用户角度衡量服务延迟。 There are similar methods to compute latency within F. 有类似的方法可以计算F中的延迟。

Regarding your two caveats: 关于您的两个警告:

  1. If data is lost, it does not have latency. 如果数据丢失,则没有延迟。 It never reached the end, so you can't measure difference between beginning and end times. 它从未到达终点,因此您无法测量开始时间和结束时间之间的差异。

  2. It's normal to have higher latency when there's increased usage. 使用量增加时,具有较高的延迟是正常的。 Report it as you usually would, no need for special handling. 像往常一样报告它,不需要特殊处理。

You should be able to figure out when "high load" is if you report your average latencies at regular intervals. 如果您定期报告平均延迟,则应该能够弄清楚何时是“高负载”。 You can create a time-series graph, and it should show a bump in latency when there are more connections. 您可以创建一个时序图,当有更多连接时,它应该显示延迟增加。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM