by toast0 · 2mo ago · 0 comments
The important thing in most distributed systems is having an order. Having a single observer serialize events as it receives them is so much more tractable than trying to use absolute order. Using absolute order requires very precise time synchronization which is hard; using absolute order requires knowing when you have received all the reports of events that already happened which is hard. Determining a designated observer isn't typically easy, but having it determine the order it observes events is easy. If two events happen at a similar time it's typically not a big deal which one is considered first as long as all nodes will agree on the result --- let the designated observer just pick the first one it sees works pretty well. If your report takes an unexpectedly long time to make it to the designated observer, then it won't be first and you'll deal.
Much better than trying to figure out unknowable questions of relativity. :P
Nodes shouldn't be observers. End users should be the observers. The ordering of event only matters from the perspective of the "I'm adding this to my shopping cart and clicking the buy button and then it said I bought it" story being internally consistent. The observer here is the end user and the end user knows what happens-before relationships were.
Databases should flip this ordering inside out and let the observers (or proxies for them) report what they did in which order. And it just happens that protocols for doing this already exist: distributed tracing encodes these relations.
A meaningful global order doesn't exist and attempts to conjure one only conjure a meaningless one, or one that throws away a lot of turns trying to perfectly order everything from some arbitrary internal observer.
If there's only one of the item to buy and two users wanted to buy it at the same time, it can only be shipped to one of them.
From each user's perspective, their add to cart (and maybe their click to buy) happened before the other user's, but alas, there is only one item available for immediate shipment.
Allowing customers to arbitrate a dispute over control of the item doesn't always go so well; see examples on Black Friday.
Even without a conflict over a mutually exclusive resource, it is valuable in many contexts for all users to share the order of observed events. That's difficult if user agents send events directly to all other agents and report observations to the user as soon as the remote reports arrive.
If A and B both report events and some users see A then B while others see B then A, there may be confusion and a poor user experience. Of course, for some things, relative ordering is unimportant.
personally I find when you view events in a distributed system as a partial order, its more liberating than confusing. its not unusual to assume that there is some kind of canonical event ordering that we have to preserve, when its often just not semantically important. so its a useless constraint that can impose complexity and limit the solution space. the partial ordering exposes the real causal constraints.
Presumably relativity is the reason precise time synchronization (and thus absolute ordering) is hard.
Imagine you take three atomic clocks, synchronize them, and move each within exactly 1 meter of one of those nodes, directly connected in an identical manner. Relativistic effects are constant. If there are elevation differences, you factor it once and done. The problem with this setup is not relativity. It is quantum uncertainty (and various interference sources, thermal radiation, etc).
You might be able to control the latency on a LAN, but once you have servers in different locations, good luck. (GPS helps a lot, of course...)