r/sysadmin • u/happysysadm • May 13 '19
How many NTP server should we have?
Based on what I could read out there, there's no consensus on the number of NTP servers a company should have in its infrastructure.
According to Segal's law - "A man with a watch knows what time it is. A man with two watches is never sure" - we shouldn't be using two NTP servers because there's no tie breaker. An odd number of servers is suggested.
Redhat - https://access.redhat.com/solutions/58025 - says that:
- it is NOT recommended to use only two NTP servers. When NTP gets information from two time sources and the times provided do not fall into a small enough range, the NTP client cannot determine which timesource is correct and which is the falseticker.
- If more than one NTP server is required, four NTP servers is the recommended minimum. Four servers protects against one incorrect timesource, or "falseticker".
An interesting blog post on NTP myths - https://libertysys.com.au/2016/12/the-school-for-sysadmins-who-cant-timesync-good-and-wanna-learn-to-do-other-stuff-good-too-part-5-myths-misconceptions-and-best-practices/ - says that:
- NTP is not a consensus algorithm in the vein of Raft or Paxos; the only use of true consensus algorithms in NTP is electing a parent in orphan mode when upstream connectivity is broken, and in deciding whether to honour leap second bits.
- There is no quorum, which means there’s nothing magical about using an odd number of servers, or needing a third source as a tie-break when two sources disagree. When you think about it for a minute, it makes sense that NTP is different: consensus algorithms are appropriate if you’re trying to agree on something like a value in a NoSQL database or which database server is the master, but in the time it would take a cluster of NTP servers to agree on a value for the current time, its value would have changed!
Looking at the Active Directory model, there is only one Master Time Server, the PDC Emulator, but we know that this role can be seized by another Domain Controller in case of failure, so the number of potential Master Time servers equals the number of Domain Controllers.
Reading a USENIX article - https://www.usenix.org/system/files/login/articles/847-knowles.pdf - I find:
- Hint: Use either just one or at least three or more, because the person with two clocks never knows what time it is - source http://www.quotationspage.com/quotes/Segal’s_Law
- In fact, you should use at least four or five upstream clocks if you want to be able to have one or more of them die or go insane, while your clock continues to function correctly. More information can be found in Section 5.3 of the CSD - source http://ntp.isc.org/bin/view/Support/SelectingOffsiteNTPServers
So, one, three or four? What's your take on these numbers?
EDIT: Some answers refer to a fully Windows infrastructure, which is not what I was talking of. I'd like just to know what's the conceptual number of NTP nodes, in a mixed environment composed of, say, Windows, Linux, both physical and on hypervisors. My bad if I wasn't clear enough in my request.
EDIT: Found an explanation of why four is better than three at http://lists.ntp.org/pipermail/questions/2011-January/028321.html:
Three [servers] are often sufficient, but not always. The key issues are which is the falseticker and how far apart they are and what the dispersion is. A falseticker by definition is one whose offset plus and minus its dispersion does not overlap the actual time. So, if two servers only overlapped a little bit, right over the actual time, they would both be truechimers by definition, but if a falseticker overlapped one of them bu a large amount, but fell short of the actual time, it could cause NTP to accept the one truechimer and the falseticker and reject the other truechimer.
34
u/VA_Network_Nerd Moderator | Infrastructure Architect May 13 '19
The answer depends on how accurate, and robust the environment in question needs to be.
If this is a mom & pop chain of three grocery stores across town? Just use the NTP-pool.
If this is a small business of 100 users and a dozen servers, the NTP-pool might still be the right solution, or you might want 3 internal servers.
If you are building out a new ISP carrier grade infrastructure, then maybe you want 3 or 5 Grand Masters.
There is no singular correct answer.
You need to leverage the combined knowledge offered by all of those sources and craft your own best-practice for your specific environment.
3
u/L3T May 13 '19
3 if you have to have your own. Need to have a majority if one is out.
3
u/theevilsharpie Jack of All Trades May 13 '19
The minimum NTP servers needed to detect a falseticker is three, but there's no reason you couldn't use more. In fact, I'd recommend doing so, as upstream NTP servers may be intermittently unreachable.
In our setup, we have five local NTP servers, each of which are use a random sampling of five NIST servers for their upstream time. They also peer with each other, and can maintain time sync in orphan mode if connectivity to the Internet is lost for whatever reason.
Here's a sample from one of our NTP servers:
Notice the "reach" column, which is an octal value that determines how many query attempts received a successful response. Many of my upstream servers have less than 377, which means a query failed to receive a response at least once over the past eight attempts. If I only had three upstream NTP servers, a failed query would have temporarily broken my ability to detect falsetickers.
Here's a sample of a downstream client of my NTP servers:
Despite not having any local GPS receivers or other Stratum 1 hardware (just syncing purely over the Internet), I can keep my time synced to within 10 ms, and the NTP server that this client has chosen is only about 1 ms off.
For some of our branch offices that don't have local NTP servers, we point to 10 servers from the NTP pool, since that's the max number of servers that can be synced with in NTPd.
I may be able to get better performance with newer NTP software like Chrony, but since implementing this setup, we haven't had any complaints about time drift, and it basically just runs itself.
4
u/AtarukA May 13 '19
PDC as main time server, other DCs sync to the PDC, clients sync to either the other DCs that is more local to them or to the PDC.
THat's how I set it up at least.
3
u/[deleted] May 13 '19
pool.ntp.organd stop worrying about it if you're not in an industry where ridiculously exact time is a requirement.As a hobby (sad, I know), I have a couple of GPS disciplined NTP servers in the NTP pool. It's not much work or money building up a couple of Raspberry Pis with GPS modules, really, if you want very accurate time without spending thousands on off-the-shelf NTP server appliances.
It all depends. Microsoft's NTP client is pretty sucky and only really uses one server at a time as far as I'm aware. If you're on 100% Windows, I'd point your PDC emulator (and in fact the rest of your DCs) at the NTP pool with a GPO, and have your clients sync off that. If you want an on-premise time server I'd just stick to the one, and configure the appliance to get a rough idea of the time from the NTP pool or similar.
If it's a mix I'd be inclined to set up the above mentioned Pis (or buy an appliance if you like to have fingers to point) and point all your systems at it with GPO or similar. Don't bother with AD sync in this case, just because it removes an element of complexity - 'which system is my PDC emulator' etc etc. I'd say three or more of these in a pool would be a good number to aim for if time is extremely important.
5
u/[deleted] May 13 '19
We use 5 external ones mostly so if any of them goes down (unlikely, but happened one or twice) nobody loses sleep over that. That goes to 3 internal ntp servers (just because they are on servers where other services needed to have 3 nodes).
As long as you are not running distributed services depending on clock being within few hundred ms of eachother, you should be fine with less
1
u/citybiker837105 May 13 '19
almost 99.99% of the time the right answer is chronyd (instead of ntp) with 4 servers referenced.
3
u/SpectralCoding Cloud/Automation May 13 '19 edited May 13 '19
I just had this discussion internally. Here is what hours of research boiled down to for our organization which has servers around the world.
Edit:
To more directly answer your questions: Your internal clients should point to either 1 or 3+ internal NTP servers. Unless you have to meet some regulation or something I think pointing all servers to a single internal NTP server is probably OK unless you already have a requirement to set up 3 NTP servers anyway. Taking an NTP server down to patch shouldn't cause harm in your environment. Your internal NTP server should be pointed to the closest government-run time service and preferably 3-5 of their redundant servers.
Here's the ones I proposed internally:
3
u/BlkCrowe May 13 '19
Confucius say only time will tell.
3
u/DeadOnToilet Infrastructure Architect May 13 '19
Coming from an environment where we had to maintain time accuracy down to MS levels, we always had four GPS NTP clocks (which we also validated through a monitoring process against NIST timeservers).
Four clocks split evenly between two geographic sites meant best-case we had no issues with falseticker overlap issues if two in the same site had problems at the same time.
2
u/LateralLimey May 13 '19
We setup a dedicated NTP box, that syncs with a ntp pool out on the internet. We designated an AD server as a primary Windows time source, and the point all other AD servers towards that box.
The reason we did that as we found out quite a few of our *nix boxes, phone system, and network gear would not pull time from the AD servers. Which was a pain.
2
u/pdp10 Daemons worry when the wizard is near. May 13 '19
NTP clients should normally be configured with four NTP sources. They don't have to be on-site or in-house, but it's an optimization to have as many of them as possible be on-site or in-house. You always have the option of running your own
pool.ntp.orgzone and answering with your internal servers, or using firewall rules to remap requests toudp/123from external servers to internal (you can also do this with DNS).If four sources aren't available, having three or two isn't a problem. While normally having two sources would lead to ambiguity, the NTP algorithms will select a source by monitoring variance and jitter, so having two sources configured is never bad. Besides, one of them could be down and you'd be happy to have two. NTP implementations won't simply switch between time sources and cause you any problems.
ntpdate, on the other hand, is crude and could do that.1
u/pythonbashman Product Support Engineer May 13 '19
In a large enterprise I could easily see the following: 3 pools load balanced each with enough resources to handle 2/3 of the entire enterprise.
You could start with obvious over engineering and see how much they're used over say a week. Then cut the pools in half. Monitor again. Repeat. One you reach a threshold you don't want to be at add 50% more and sit there for a while. Every time you reach 70% usage, add another 50% resources.
Also watch your services that use NTP and see how long they are waiting. There are some services that are extremely sensitive to NTP not being available.
0
u/switchdog May 13 '19
The NPO I work with has an Internal NTP server (Symmetricom SyncServer PTP Rubidium), with a firewall rule to only allow the PDC and DC to reach pool.ntp.org.
-1
u/Deshke May 13 '19
as with any mesh service at least 3/5/7/11 to get a quorum