Understanding Event Timestamps

Hello everyone,

we have a problem with some timestamps in one of our applications.
Rarely we have 5-10 events with the same timestamps (to the milisecond) on our application server.
I queried the events using the node manager on the server locally. The events were created on a tablet app. It should not be possible to create the events at the same time at once using the ui.
How does a timestamp of an event get created?
Is the timestamp created on the device it was published?

We rely on the event timestamp (using event.meta.timestampMacros) to generate a timestamp for a database entry.
Could it be possible that the device was disconnected from wireless for a short time, after which those events have stacked up and were published at the same time with the same timestamp?

Here you can see an example:
This is from the node manager query on the application server.
The events were created on a tablet device.


Event timestamps are generated inside Actyx as soon as they have entered the process via the HTTP API. If the publish() call in the app included multiple events, then all of them get the same timestamp (to the microsecond), but different Lamport timestamp and offset — the Lamport timestamp is what determines the event order in the Actyx system, so ordering is preserved even when the wall clock timestamp is the same or even decreasing (which can happen when the clock is turned back in the operating system).

That being said, it is well possible that multiple event emissions from Javascript reach Actyx within the same millisecond on modern hardware. Without seeing your application code I cannot tell whether that is expected, but I can say that event emissions are buffered inside the Actyx SDK only while there is no connection to Actyx. If you’re using the latest version you can use the onConnectionLost and onConnectionEstablished callbacks in the SDK options to observe the connection status.



Thank you as always for the fast response.
We only do one event per publish call.
For example if the tablet would be disconnected from the actyx network for some time,
would all those buffered events during that time get the same timestamp once reconnected?

Event timestamps are produced by the Actyx node itself, meaning whether or not the device is connected to Wifi will have no impact on timestamps. The SDK and Pond communicate with the local Actyx node via localhost irrespective of whether the node is connected to the network (or in Airplane mode).

A local node will create events with equal timestamps if

  • The events are published sequentially but quickly enough to happen within the same millisecond
  • The events are published in parallel (e.g. publish([event 1, event2]))
  • The events SDK/Pond buffer while unable to connect to the local Actyx node (e.g. it crashed)

Does that make sense?

Reg. DB unique keys: could you use the event ID instead of the timestamp?