Joa*_*rel 25 synchronization clock azure
我正在寻找Windows Azure上虚拟机之间时钟偏移的定量估计- 假设所有虚拟机都托管在同一个数据中心.我猜测一个VM和另一个VM之间的平均时钟偏移低于10秒,但我甚至不确定它是Azure云的保证属性.
有没有人对此事进行定量测量?
Joa*_*rel 27
我终于决定自己做一些实验了.
关于实验方案的一些事实:
Stopwatch对于简约的未经身份验证的请求,存储和测量的VM之间的延迟总是低于1毫秒(基本上HTTP请求返回400个错误,但仍然Date:在HTTP头中可用).结果:
从技术上讲,我们距离2s容差目标并不太远,但对于数据中心内同步,您不必将实验推向远近观察接近4s的偏移.如果我们假设时钟偏移的正常(又称高斯)分布,那么我会说依赖于低于6s的任何时钟阈值必然会导致调度问题.
/// <summary>
/// Substitute for proper NTP (Network Time Protocol)
/// when UDP is not available, as on Windows Azure.
/// </summary>
public class HttpTimeChecker
{
public static DateTime GetUtcNetworkTime(string server)
{
// HACK: we can't use WebClient here, because we get a faulty HTTP response
// We don't care about HTTP error, the only thing that matter is the presence
// of the 'Date:' HTTP header
var tc = new TcpClient();
tc.Connect(server, 80);
string response;
using (var ns = tc.GetStream())
{
var sw = new StreamWriter(ns);
var sr = new StreamReader(ns);
string req = "";
req += "GET / HTTP/1.0\n";
req += "Host: " + server + "\n";
req += "\n";
sw.Write(req);
sw.Flush();
response = sr.ReadToEnd();
}
foreach(var line in response.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries))
{
if(line.StartsWith("Date: "))
{
return DateTime.Parse(line.Substring(6)).ToUniversalTime();
}
}
throw new ArgumentException("No date to be retrieved among HTTP headers.", "server");
}
}
Run Code Online (Sandbox Code Playgroud)
我最近与Azure产品团队的人就时钟同步进行了对话,更多的是出于兴趣而不是其他任何事情.我收到的最新回复是:
虚拟机和服务在启动时直接从底层Hyper-V平台消耗时间,从那时起,服务维护时钟.为了在分布式系统中实现真正的时间同步,您需要在应用程序层和/或引用单个时间服务器的服务上执行此操作.
| 归档时间: |
|
| 查看次数: |
8985 次 |
| 最近记录: |