PHP microtime() drift, External NTP service

前端 未结 3 778
感情败类
感情败类 2021-01-16 13:38

I am looking for a solution for an issue on my cloud-hosted server where the result returned from microtime(true); is very accurate between calls within a few minutes of eac

3条回答
  •  旧时难觅i
    2021-01-16 14:20

    High-precision clock synchronization is going to be problematic, especially in a virtualized environment. This is the exact case for the recommendation of not running Kerberos/Windows domain controllers in a virtual environment given their tendency to high clock drift.

    That said, the correct answer is certainly not to spam NIST in any form as they provide NTP services as a courtesy and will most certainly block you for excessive queries.

    What you should do is ask your ISP if they have an NTP server that you can use to aggressively sync your clocks, ideally a stratum 1 or 2 server, and point all of your machines at that. If not, set up your own stratum 2 server [preferably on metal, not virtual] and use that.

    Once you have a suitable NTP server then it's just a matter of configuring ntpd to update your clock frequently enough from that one server that you don't end up drifting more than you 10ms limit.

    But really, I can't shake the feeling that requiring these disparate clocks to be so closely in sync is a symptom of a poor design choice. Can you not simply send these 'asynchronous clients' their scheduling info as 'X microseconds from now' rather than a full timestamp in the future?

提交回复
热议问题