Sir Falk
Sir Falk

Reputation: 123

Why is no global time such a big issue in distibuted systems? When would a global time be useful?

It's no hard for me to understand why a global time cannot really exist or at least be measured in a distributed system. However, I don't really understand why this is such a big issue. I mean most code is executed sequencially anyway, or in a causal relation (so something like A then we can use it in B then execute C). I've never seen code that was like "it's critical, that these two threads execute something at the exact same time". In what scenario would it be useful to have a global time?

Upvotes: 2

Views: 203

Answers (1)

djechlin
djechlin

Reputation: 60828

I mean most code is executed sequencially anyway

I disagree. That's true almost by definition for a single process on a single thread. But if Taylor Swift drops a new album on twitter and 1M of her 88.7M followers like it, they don't have to wait in a queue for the other 1-999,999 users to finish their "like" update. (Or at least, the data structure is much faster than taking out a heavyweight lock to guarantee sequence.) There's a lot of nonsequential code there.

or in a causal relation (so something like A then we can use it in B then execute C).

Right, and a naive clock-based implementation does not implement causality. Say the true order of events is this:

Initially: x = 1
Process 1: set x = 2
Process 2: read x
Process 2: if (x == 2) set x = 4

But we rely on their clocks it might look like:

Process 1: set x = 2 (t = 4:00:00)
Process 2: read x (t = 3:59:59.000)
Process 2: if (x == 2) set x = 4 (t = 3:50:59.100)

The replicas might rely on timestamps to replay these operations and use timestamps to sort them. Relying on skewed clocks would violate the causality.

Upvotes: 1

Related Questions