CF Worker and DO Clocks Tests

This page demonstrates that a Cloudflare durable-object's clock loses time across requests, and that the more computation work the durable-object does, the more time it loses. It also demonstrates that a Cloudflare worker's clock does not lose time in this way.

This page logs information about the delta between its clock and the clock of a Cloudflare worker or durable-object as observed over a series of requests. It has three test cases. In each test case the page sends its current time as reported by Date.now() every 250ms to a worker (which depending on the test case may forward it to a durable-object). The worker or durable-object responds with an array containing the timestamp it received from this page and its current time as reported by Date.now(), and starts a configurable amount of async computation work. This page then logs the round trip time and the delta between the page and server timestamps.

The three test cases are:

  1. worker-post: time is sent via a POST request which is responded to by the worker with the worker's time.
  2. do-post: time is sent via a POST request which is responded to by the durable-object with the durable-object's time.
  3. do-websocket: time is sent via a WebSocket message which is responded to by the durable-object via a Websocket message with the durable-object's time.

Note that for all these cases the round trip time remains steady. For the worker-post test case, the delta between the page and server timestamps also remains steady, showing no time loss. However, for both do-post and do-websocket, the delta between the page and server timestamps becomes smaller over time showing time loss. Increasing the work (i.e. computation) done per request increases the rate of time loss.

Select test:

Select work per request/message:


Log (new messages are prepended)