Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dealing with an inaccurate system clock

I have a windows based system that sits on an Amazon EC2 instance. There is a known issue that Windows EC2 instances have problems keeping their system time in sync. I'll randomly log into the system and find that my system clock is anywhere from a couple seconds off (not too big of a deal...) to several minutes or even hours off (obviously a huge deal).

Considering that my site's prime objective is to issue out links to secured S3 content that is locked down by a considerably strict time limit (ie sometimes as little as 30 seconds to a minute), this is a huge issue for me. Scouring Amazon's help forums has yielded many answers that simply do not work and Amazon seems to be ignoring the issue claiming it's Windows related. Regardless, I've decided to take things into my own hands and not to wait on Amazon.

Things I've considered:

  • Creating a service that hits a list of time servers every hour or so, gets the current time, calculates the offset, and then uses this offset to generate accurate links. The downsides being that I need to have a substantial list of time servers so that they don't block me from hitting them too often. Also, if the time gets randomly fixed in the middle of one of these periods, my links will start breaking again.
  • Creating a Linux EC2 instance and finding some way of getting its internal time. I haven't read anything on how accurate their times are within EC2, but I would have to assume it's better that this nonsense.
  • Hosting my site elsewhere that has accurate clocks...

Are there any other options you can think of that I may have missed? I'm not really opposed to anything with the one exception being rewriting my site in another language so as to move away from Windows (it's a .Net MVC application currently).

Thanks in advance!

EDIT: Also of note, I can not use referrer based security as the plugins I'm utilizing that use these links don't 100% send the referrer in some browsers.

like image 221
jamesmillerio Avatar asked Oct 25 '22 02:10

jamesmillerio


1 Answers

It's strange that your servers should drift several hours. By default, Windows Server 2008 R2 is configured to NTP-sync its clock with time.windows.com every 900 seconds (15 minutes). If this does not get you the required timeliness, you can increase the frequency by modifying a registry key.

If you're hosting a ASP.NET application, you should consider running it on AppHarbor. We run on top of of EC2, but take away dreary server management tasks like making sure clocks are in sync.

like image 200
friism Avatar answered Oct 26 '22 23:10

friism