On Mon, Jan 12, 2009 at 9:59 AM, Cesium <cesiumpic...@gmail.com> wrote:
>> > > Marzia  in this thread has already said they dont offer any guarantees.
>>
>> > Is Marzia a primary source?
>>
>> Yes, Marzia is part of the app engine team.
>
> I'm hosed.

Cesium,

What algorithm are you trying to implement that requires synchronized
clocks? To my knowledge it's a pretty well-known best-practice to
never rely on clocks being the same across a distributed system. Some
algorithms can take advantage of closely correlated clocks, but I
believe they never need anything better than the guarantees of NTP
(http://en.wikipedia.org/wiki/Network_Time_Protocol), which is
essentially what App Engine provides.

If you need a guaranteed ordering of time, there are a few ways to do
this. One simple way is to use a set of incrementing sequence numbers
in the Datastore. Every time an event happens, you transactionally
increment the sequence number and write the event record to the
Datastore. Then it doesn't matter what the timestamp is on the record,
the events will always be ordered by the absolute time that they came
in. This has some scalability issues (because you essentially have a
global counter). But if you can partition your data reasonably, you
could probably optimize throughput quite a bit.

Another way is to use a technique like Andy Freeman mentioned. Every
time you store an event record, you also write the new maximum
timestamp to the Datastore (or preferably memcache). To determine that
initial timestamp, you can query for the maximum timestamp record with
the latest timestamp. This will likely result in events that happen at
exactly the same time, though.

If you need to guarantee that you always have ascending timestamps
that are never the same, then you'll need to use a
sequence-number-like solution as I described before. To make this
scale correctly, you would want to partition your sequence number
counters based on the event incidence time. That way if you got two
events at exactly t=10.123 seconds, you could do two transactional
updates and end up with one event at t=10.1230 and another at
t=10.1231. The throughput of this solution will depend on the
resolution of your clock. I hope that all makes sense.

-Brett

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to