Knowledge Guide
HomeSystem DesignScalable Systems (Advanced Topics)

hard What Is the Difference Between Wall‑Clock Time and Monotonic Time, and Why Is Clock Skew

Wall-clock time (system “real time”) is the machine’s current date/time of day, which can jump forward or backward when the clock is adjusted (by NTP sync, daylight savings, manual change, etc.), while monotonic time is a steadily increasing timer (often since boot) that never goes backwards.

Clock skew is the drift or offset between different clocks (for example, on different servers), which is hard to eliminate because each clock runs at a slightly different rate and network sync protocols can’t perfectly align them.

Wall-Clock Time (Real Time)

Wall-clock time (also called system time or real-time clock) represents actual calendar time.

It answers questions like “what time of day is it?” and is used for timestamps, scheduling tasks, and logging.

Because it reflects human time (UTC/local time), it can be adjusted by external events: for instance, a time-sync service (NTP) might set your clock forward a few seconds, or a user could manually change the system time.

Such adjustments mean the wall-clock can jump or even move backwards (e.g. after a backward NTP update).

In practice, wall-clock is great for events tied to real time (e.g. “run this job at 6:00 PM”), but programs must handle the fact that the clock can be reset, adjusted for leap seconds, or synced with internet time.

Learn about Vector Clocks.

Monotonic Time

Monotonic time is a special clock that only measures elapsed time. It typically counts continuously from a fixed point (such as system startup) and always increases at a steady rate.

Because it isn’t linked to the real-world date, it cannot be changed or set by the user or NTP. It will never jump backwards or forward.

This makes it ideal for measuring durations, timeouts, or intervals.

Key Differences

Unlike wall-clock time, monotonic time is immune to manual or automatic adjustments.

Wall-clock can be synchronized across machines (so 6 PM here means 6 PM there), whereas each machine’s monotonic clock is independent (each starts from its own zero).

Crucially, when measuring elapsed time, monotonic timers guarantee a non-negative interval, while wall-clock measurements might even go negative if the clock is set back.

Difference Between Wall‑Clock Time and Monotonic Time
Difference Between Wall‑Clock Time and Monotonic Time

Clock Skew and Synchronization

Clock skew refers to the differences or drift between clocks, typically in a distributed system with multiple machines.

Even if all clocks are initially synced, each hardware clock “ticks” at a slightly different rate, so over time their readings diverge.

The difference in rate is called skew, and the difference in current time is called offset.

For example, imagine two clocks that start in sync.

If one runs just a tiny bit faster, after a while it will show a later time than the other; that growing gap is clock skew.

Why Clock Skew is Hard

Eliminating clock skew is challenging because there is no perfect global clock and physical limitations introduce error.

Some key reasons:

Because of these factors, complete elimination of skew is impossible.

In distributed systems, this makes tasks like globally ordering events by timestamp difficult.

For example, if Server A’s clock is a second ahead of Server B’s, an event logged at 12:00:01 on A might actually have happened after an event at 12:00:02 on B, causing confusion.

In practice, systems either tolerate some skew (e.g. by including clock uncertainty in algorithms) or use logical clocks (Lamport timestamps, vector clocks) that avoid relying on synchronized physical time.

Summary

Wall-clock (real) time and monotonic time serve different needs.

Use monotonic timers for measuring elapsed time to avoid jump-induced errors.

Clock skew is the inevitable mismatch between clocks. It is hard because every clock drifts and network sync is imperfect.

Understanding the difference and the limits of synchronization helps developers choose the right clock and design robust, time-sensitive code.

🤖 Don't fully get this? Learn it with Claude

Stuck on What Is the Difference Between Wall‑Clock Time and Monotonic Time, and Why Is Clock Skew? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🪜 Hint ladder (no spoilers)

Progressively stronger hints — you still solve it.

I'm working on the problem **What Is the Difference Between Wall‑Clock Time and Monotonic Time, and Why Is Clock Skew** (System Design). Give me a HINT LADDER: start with the tiniest nudge, then wait. Only reveal the next, stronger hint when I ask. Do NOT show the full solution unless I type 'show solution'. Keep me doing the thinking. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🎨 Explain the approach visually

See the technique, not just code.

Explain the optimal approach to **What Is the Difference Between Wall‑Clock Time and Monotonic Time, and Why Is Clock Skew** with a VISUAL walkthrough: trace it on a small concrete example using ASCII art / a step-by-step diagram, narrate what changes each step, then give time & space complexity with a one-line derivation. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🔍 Review my solution

Catch bugs, edge cases, sub-optimality.

I'll paste my solution to **What Is the Difference Between Wall‑Clock Time and Monotonic Time, and Why Is Clock Skew**. Review it for correctness, missed edge cases, and time/space complexity, then coach me toward the optimal — don't just rewrite it. Ask me to paste my code now. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🔁 Drill the pattern

Lock in recognition with look-alikes.

Give me 2 problems that use the SAME underlying pattern as **What Is the Difference Between Wall‑Clock Time and Monotonic Time, and Why Is Clock Skew**. For each, let me attempt first, then review my answer and name the trigger signal that reveals the pattern. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes