Onboarding Step Timestamps Across Services With Clock Skew
When the service that completes a step and the service that records it disagree on the time, ordering breaks. Here's how to keep step history correct.
An onboarding checklist looks like a single timeline to the user: step one, then step two, then step three. Underneath, it's rarely one clock. The app server that marks a step complete, the background worker that verifies a webhook, and the database that stores the row can each report a slightly different "now." Most of the time nobody notices. The problem shows up the day two steps complete within the same second and the checklist renders them in the wrong order — or a step appears to finish before the action that was supposed to trigger it.
Why skew matters more for onboarding than for most features
A lot of application logic tolerates a few hundred milliseconds of disagreement between servers because the events in question aren't ordered relative to each other — a page view doesn't care what time the database thinks it is. An onboarding checklist is different: its entire value is sequence. "Connect your account" has to visibly happen before "invite your team," because the second step's completion logic might depend on data the first step created. If your step-completion API accepts a client-supplied timestamp, or your workers aren't on tightly synced clocks, skew turns a deterministic sequence into a race.
Where the disagreement actually comes from
Three sources cover almost every case worth planning for:
- Client clocks. If a step is marked complete using a timestamp sent from the browser or a mobile client, you are trusting a clock you do not control and that is sometimes wrong by minutes, not milliseconds — users change timezones, phones drift, corporate laptops get locked to stale NTP servers.
- Worker and queue latency. A step completion that is processed asynchronously (a webhook handler, a queued job) can be recorded well after the event that caused it, especially under load. The timestamp the job assigns depends on when it ran, not when the action happened.
- Database server clocks. If you let the database assign
created_atwith its ownnow(), and your database runs on different infrastructure than your app servers, those two clocks can disagree by a small but non-zero amount even with NTP running everywhere.
Stop relying on wall-clock time for ordering
The fix that generalizes is to separate two concerns that timestamps usually try to do at once: when something happened and in what order things happened. Wall-clock time is good for the first and unreliable for the second when multiple services are involved. For ordering, use a value that is monotonic and assigned by one authority — typically the service that owns the checklist's state, not the client and not a worker.
A simple, durable pattern: give every step-completion event a sequence number from the service that writes it to the database (an auto-incrementing column, or a single counter per account), and keep the human-readable timestamp as a separate, informational field. The sequence number decides what the checklist renders as "first" and "second." The timestamp is still stored and still shown to the user, but it is never read to decide order. This removes skew between client, worker and database as a source of visibly wrong step order, because only one place assigns the number that matters.
What to do when the event genuinely originates elsewhere
Sometimes the real-world event — a payment clearing, a third-party OAuth grant completing — happens on infrastructure you don't control, and its timestamp is the only record of when it actually occurred. In that case, keep that external timestamp as evidence (useful for support, audits, debugging) but still assign your own sequence number at the moment your system learns about it and writes the row. Two different questions get two different fields: "when did this really happen out there" and "where does this sit in the checklist I'm rendering." Conflating them is what produces the bug where a step the user swears happened "first" renders second, because the external timestamp was earlier but your system heard about it later.
A narrower case: steps completed by different services
If step completion can come from more than one service — your main app, a billing service, a partner integration — route all of them through one completion endpoint or one database write path that assigns the sequence number, rather than letting each service write its own row with its own clock. This is the same principle as previewing a checklist before shipping it: a single source of truth for state beats several sources that are each individually reasonable but collectively inconsistent. If that's not practical because the services genuinely write independently, the fallback is a distributed ordering primitive (a Lamport-style logical clock, or a vector clock keyed per account) — more machinery, and worth it only once you've confirmed wall-clock ordering is actually producing visible mistakes, not just theoretical ones.
What to measure instead of guessing
No clock-skew number is quoted here because none has been measured on this system, and a generic NTP drift figure from somewhere else would not describe your infrastructure. Before changing anything, instrument the actual gap: log both the wall-clock timestamp and the assigned sequence number for every step completion, then query for cases where two completions for the same account have timestamps out of sequence-number order. That count — not an assumed millisecond figure — tells you whether this is a real problem for your checklist or a theoretical one you can leave alone for now.
The practical takeaway
You don't need synchronized clocks across every service to get onboarding step order right. You need exactly one place that assigns the number the checklist trusts for ordering, and you need timestamps to stay a separate, honest record of wall-clock time rather than a secret ordering mechanism. Get those two things right and clock skew stops being a source of wrong-looking checklists, even if the clocks themselves are never perfectly synced. See how step state is exposed via the API reference, or read how a related edge case is handled in onboarding step completion visible only after replica lag.