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.
- Consistency & Consistency Levels
- Consistency Models — Strong Consistency Models
- Consistency Models — Session & Eventual Consistency Models
- 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 -
- Distributed Data Stores for consistency reasons as already discussed.
- Event-Driven Systems where any event can trigger a series of ordered calls to different services.
- 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.
- 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.
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 -
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?