My current project isn't very time-sensitive, but my previous one we saw servers up to 45 minutes slow. Made it hard to make fetches from Amazon S3 buckets with a 30-minute signed token when it was already expired by 15 minutes...
On Thursday, July 25, 2013 2:27:04 PM UTC-5, Richard wrote: > > My experience is that GAE backends are horrible when it comes to the 'NTP > correct' time. I have seen servers as much as 20 minutes out. For the > last 6 months or so, they have been much better, so maybe Google got its > act together. > > Since I run a MMO synchronized client (android) server (GAE) game, I need > everyone to be correct to within 1-2 seconds. The following code works > pretty well: > > url = "http://www.worldtimeserver.com" > format = '%a, %d %b %Y %H:%M:%S %Z' > correction = 0 > try: > orig_timestamp = time.mktime(time.gmtime(time.time())) > result = urllib2.urlopen(url) > date_string = result.headers['Date'] > recv_timestamp = time.mktime(time.gmtime(time.time())) > dest_timestamp = time.mktime(time.strptime(date_string, format)) > > correction = int((recv_timestamp - dest_timestamp)/2%180.) > > Reason for the %180 in there is the games are on a 3 minute boundary. > > > I rarely see more than 1-3 seconds of 'correction' needing to be applied > nowadays. > > > On Thursday, July 25, 2013 12:53:34 PM UTC-4, Evan Ruff wrote: >> >> Hey guys, >> >> I'm curious to hear about any strategies people have used to employ time >> synchronization among the AppEngine instances. I'm working on a project >> that is looking to have a pretty important time component and the current >> strategy I'm looking at is something long the lines of: >> >> 1. Record System.currentTimeMils() >> 2. URLFetch to an NTP server somewhere >> 3. Note return time >> 4. Correct NTP time using the start time to get request time. >> >> Is this how other people are handling it? Is there another way that might >> be simpler? I'm a little hesitant to run an URLFetch for each request, >> obviously. >> >> Thanks! >> >> E >> > -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-appengine. For more options, visit https://groups.google.com/groups/opt_out.
