0

I have a system that initially didn't need to control so tight the dates and times (it only worked in a single timezone), but as a requirement now we need to use multiple timezones on this system.

The problem is that this system will be prepared to run over multiple EC2 instances storing information into an Aurora instance with multiple replica servers.

Aditionally, this system will control sessions on a redis instance or AWS-like service.

My question is:

What are the best practices to control where o which service will write this dates and ensure precision on dates when saving or getting them?

I've heard that the best way to ensure the most accurate dates is using an NTP server, but also I've heard of someone that lost the connection with an NTP server and their dates had a delay when he detected it.

I have some assupmtions like:

  • Maybe the best way to store this is always on UTC and then transform the date depending on each timezone.
  • Possibly the redis or redis-like AWS service has to have it's own date control.

I know that it's not the first system dealing with this problems, but I really don't know where to start.

Thank you in advice.

MikeVelazco
  • 133
  • 7
  • 3
    Always save dates in UTC and do the conversions on that data as-needed afterwards for stuff like user output. That one random person lost their NTP connection is **not** a good reason not to use NTP on servers. NTP is the gold standard and everyone's using it. – ceejayoz Apr 20 '17 at 17:44
  • In the case of the issue with the NTP server, how can I avoid this to happen? – MikeVelazco Apr 20 '17 at 18:03
  • The default config on most systems is pretty resilient out of the box, using multiple NTP pools for redundancy. NTP problems are quite rare - freaking out about it is a waste of time. In general, once running it stays running, and problems with it are usually the admin's screwups. – ceejayoz Apr 20 '17 at 18:08
  • 2
    Use NTP. AWS has their own NTP pool. – Matt Houser Apr 20 '17 at 18:10
  • @MattHouser, then theorically every AWS service should have the "same" time? – MikeVelazco Apr 20 '17 at 19:17
  • 2
    Yes. We run a production system that is very time sensitive and we use NTP to sync the time. The worst we have ever seen was 0.5 seconds drift. – Matt Houser Apr 20 '17 at 19:24
  • 1
    @MikeVelazco All of the managed services (RDS, ElastiCache, etc.) will be running NTP. You're responsible for installing and making sure it's working on the unmanaged stuff like EC2. Depending on the AMI you use, NTP may or may not be pre-installed. – ceejayoz Apr 20 '17 at 20:18
  • *"I've heard of someone that lost the connection with an NTP server"* The problem with that thought is that when configured correctly, there is no "*an* (single) NTP server." You need to be using at least 4 of them, but you don't need to run them yourself. – Michael - sqlbot Apr 21 '17 at 01:11
  • NB: NTP is not really related to timezone. I would advise against having different timezones on interconnected systems, it not only confuses admins but also a lot of software out there (especially database clients) are just broken by assuming same time zone on write and read. – eckes Apr 21 '17 at 15:39

0 Answers0