In the past, I have seen that most of my computer on my local network don't really have the same time within up to 1 second or so.

So I wanted to make sure that it would be possible for a stack of servers (say 48 1U computers) to all have the exact same clock. I know I can use NTP for the matter and I know I can have one server get time from an atomic clock, and the others synchronized to that one server.

I have one main concerns with that technique though: If that one server breaks, then my time synchronization stops... not good at all.

Is there a proper way to make sure 48 computers all have their clock synchronized with an accuracy of about 0.5µs? If not 0.5µs, what can we hope for? (i.e. 0.5ms?)

  • A correct answer is long, complex and dependent on both hardware and OS versions. One definite limitation is you cannot keep time at a granularity finer that the OS interrupt interval, however interrupts are managed on your system. As instruction execution on the common non-realtime OSs can be automatically deferred to a later interrupt even that is not reliable for timekeeping inside of applications. I wrote a sketchy answer about this here: serverfault.com/questions/700537/… – ErikE Sep 24 '15 at 5:44
  • Ah, indeed, I did not think of mentioning that. We'd only use Linux Ubuntu, but we do not control the hardware at this time. We use VPNs which of course adds another variable in the mix! – Alexis Wilke Sep 24 '15 at 8:37

NTP can use a pool of servers (e.g. http://www.pool.ntp.org/en/ but you could build your own) to avoid the one-server-is-down case, and the servers can also maintain a local clock if for some reason all of their parent servers are unavailable.

| improve this answer | |
  • What kind of precision may I expect, because in some circumstances, my app requires a really small difference between computers... – Alexis Wilke Sep 24 '15 at 0:36
  • 1
    @AlexisWilke If you need sub-microsecond accuracy then you should be looking at PTP. – Michael Hampton Sep 24 '15 at 1:28
  • @MichaelHampton, that looks like my answer. Between using a common pool and PTP, it looks like I can "easily" set that up. – Alexis Wilke Sep 24 '15 at 3:23

I actually found a blog post with the information I was looking for. They mention that their cluster has computers properly synchronized at 1ms using NTP.

It looks like PTP, as suggested by Michael Hampton, follows the same strategy as in: it will make use of one computer, the grandmaster, as the source for time synchronization, opposed to trying to get the correct absolute time on all computers (as a result, if the grandmaster is off by 10ms from what the world considered absolute real time, all nodes will be off by 10ms).

The solution proposed in that document is to:

1) Setup one computer to retrieve absolute time with NTP. If that one computer goes down, the clocks may start drifting, but they will not become inaccurate between each others, they will be drifting compared to the absolute real time only.

In this case, you use server definitions (the grandmaster):

server 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst

Also setup this computer as an NTP server, say local.ntp

2) Setup the other computers as peers

server local.ntp   # only on a few other (3 to 5) computers
peer c0 iburst
peer c1 iburst
peer c2 iburst

You do not need to have all 48 computers connected to each others, instead you would have between 3 and 5 with each computer using a slightly different setup (c1, c2, c3, then c2, c3, c4, etc.) As a result you get a peer to peer network which synchronizes each others as closely as possible, with a few computers (3 to 5) linking to the node defined in (1), i.e. local.ntp, to get the time as close as possible to real time.

The local.ntp reference can itself be viewed as a peer (you may even be able to make it a peer?)

P.S. the use of restrict is strongly advised when using peer on a semi-public network to prevent others from accessing your NTP network.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.