6

I want a cluster of servers to have the exact same time. All are using UTC time zone.

Using NTP currently, i still see they seem to be off by 10-20 miliseconds each.

Whats the best way to have them each the exact time?

  • 3
    Are you using Public NTP server or local NTP server? Its better to use local NTP server which will help you to reduce this gap of few milliseconds which is probably due to network latency in case if you are using Public NTP servers. – Pratap Aug 29 '14 at 20:42
  • using public ntp – pdeva Aug 29 '14 at 20:45
  • 1
    probably(!!!) you have the answer now ? – Pratap Aug 29 '14 at 20:46
  • i am curious though, how does it matter. even if u are using a public ntp, after a few hours, all clocks should be exactly the same. how does latency with respect to ntp matter – pdeva Aug 29 '14 at 21:29
  • 2
    Answered here: serverfault.com/questions/508586/… – Giovanni Tirloni Sep 2 '14 at 12:50
20
+50

Connecting your ntpd to NTP servers outside your LAN to time sync can lead to the inconsistencies you are seeing, because every connection will have to go thru several routers, each one with unpredictable latencies depending on traffic. If each server connects by itself, the time between all the servers will drift a little.

To avoid the inconsistency, the best approach is to create a local NTP server, syncing time with an external NTP Server Pool, and using this local NTP server as "master clock" to your local servers:

  1. Local NTP Server

    You configure this server to sync with a NTP server on a pool geographically close to you. On this site you can get a list of servers and get one close to you. It will keep the time in sync with them.

  2. NTP Daemon on your servers

    Configure the ntpd on every server to connect to your local NTP server. As you mantain a local NTP server on a very last, low latency LAN, the skew will be minimal.

Using this implementation the time on your servers will be in sync with each other.

2

As pointed out by others, a local NTP server which syncs from a public one, and provides a low latency service for your other servers will probably be the best you can do.

You can get a very accurate external sync from GPS if you can see the sky, but that's often not practical.

I suspect if you are having problems, you have one of two issues: Either you are polling NTP (e.g. ntpdate from cron) instead of running a local daemon, or your problem is actually to do with testing and the latency in your network, and your servers might be better synchronized than you think.

2
  1. Have you considered moving from NTP to PTP? http://en.wikipedia.org/wiki/Precision_Time_Protocol
  2. If you cannot move away from NTP perhaps multicasting will help. http://doc.ntp.org/4.1.1/confopt.htm

Either way one of the obvious things to get right is good quality time source. Either get your own GPS receiver and/or atomic clock to your data center, or connect to multiple external stratum 0 clocks. Later strategy is a little uncertain. You never know what sort of clock in internet is providing it as stratum 0, they can be anything from really good clocks to grandpa's tick tocks.

p.s. Use ntpq -c peers to see stratum level of the clocks you are connecting to. More information about debugging, see http://www.clock.org/ntp/debug.html

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.