Clocks — It’s not that simple!

Yes, I know you don’t agree with me! Clocks are simple! Clocks are designed for measuring time & we know very well how to interpret them.

But, before going into this article, I’d advise you to go through the following articles to get the complete context.

  1. Consistency & Consistency Levels
  2. Consistency Models — Strong Consistency Models
  3. Consistency Models — Session & Eventual Consistency Models
  4. Consistency & Consistency Levels — Tuning Consistency Levels

In this series(Yes, this is a series as well because Clocks ain’t simple), we will talk about the different types of Clocks, how our computers & other devices can tell time and the challenges associated with tracking time in a distributed context & their solutions.

We’ve already seen in our consistency series that to establish strong consistency models, we need to establish an ordering between our operations, either total ordering or causal/partial ordering. But establishing ordering across distributed systems isn’t straightforward and that’s where we leverage clocks.

Let’s also think about use cases where we need ordering -

  1. Distributed Data Stores for consistency reasons as already discussed.
  2. Event-Driven Systems where any event can trigger a series of ordered calls to different services.
  3. Business flows like placing an order on any website. There is an ordered flow for all of these executions irrespective of the number of devices you’re working with.
  4. Logs. Logs are supposed to be ordered stream of events(even across services) & any out-of-order logs can cause a big headache during debugging.
Physical Clocks relying on Quartz crystal oscillations
Photo by Thomas Bormans on Unsplash

There are different types of clocks that we can leverage to implement ordering & in this article, we’ll talk about the clock we know best -

Physical Clocks

Real time clock within computers operates on its own power & runs a quartz crystal oscillator
Photo by Markus Spiske on Unsplash

Have you ever wondered how your computer/mobile phone can tell time? Have you wondered why most clocks are always in sync & why some are out of sync?

Pratik Pandey -

Senior Engineer with experience in designing and architecting large scale distributed systems.