Two order gateways stamp events with their own clocks, synchronised to within 3 ms of each other. Events A on gateway 1 and B on gateway 2 occur 1 ms apart in reality. Compute the probability that the recorded stamps order them wrongly under a uniform relative offset, and say what to order by instead.
Two order gateways stamp events with their own clocks, synchronised to within 3 ms of each other. Events A on gateway 1 and B on gateway 2 occur 1 ms apart in reality. Compute the probability that the recorded stamps order them wrongly under a uniform relative offset, and say what to order by instead.
Approach: Model the relative offset between the two clocks as a single random variable, then find the event in which that offset exceeds the true gap between the two occurrences.
1/3. Let d be the relative offset of clock 1 against clock 2, uniform on -3 to 3 ms. A is recorded at t + d and B at t + 1, so the recorded order reverses when d > 1, which has probability (3 - 1) / 6 = 1/3. In general P = (s - g) / (2s) for a clock skew bound s and a true gap g, so events closer together than the skew are ordered close to at random and only gaps well beyond 3 ms are safe. That is why a wall clock stamp is a poor ordering key at microsecond scale, and why comparing two gateways' stamps to decide which arrived first is a reconstruction rather than a measurement. What to use instead depends on the scope. Within one venue use the venue's own sequence number, which is a total order by construction. Across services carry the happens before relation explicitly through a causal token or a logical clock incremented on send and merged on receive. Where a physical stamp is genuinely required, use a clock exposing a bounded uncertainty interval and treat two events whose intervals overlap as unordered, which is honest about the 3 ms rather than hiding it inside a comparison.
Follow-up: How large must the true gap be for the reversal probability to fall below one in a thousand at the same skew bound?
Key concepts: clock skew, relative offset, happens before relation, sequence number.