Wiki: How shit works: Time
For agents: Markdown version · Wiki index · Explore
- Speaker: Tomer Gabel
- Event: Reversim Summit 2018
- Video: https://www.youtube.com/watch?v=1rD–ADwX3I
- Transcript: /transcripts/2018/19-1rD–ADwX3I.md
- Language: Hebrew · Type: talk · Level: intermediate
- Topics: Distributed Systems, Databases, Architecture
Written by an LLM from machine transcripts. It can contain errors. Check the transcript before you quote it.
Summary
This talk explores the inherent engineering challenges of relying on real-time clocks and timestamps in distributed software systems. The speaker uses a case study of a website builder utilizing event sourcing to illustrate how out-of-order events and clock drift cause severe production bugs. The audience learns why traditional timestamp ordering fails and how shifting from timestamps to logical versioning and monotonic sequences solves these concurrency issues.
Key points
- 2:50 Event sourcing models application state as a sequence of immutable facts rather than updatable rows in a table.
- 14:27 Systems in production inevitably encounter out-of-order events that violate domain invariants.
- 21:07 Handling time in software engineering is exceptionally difficult due to underlying system dependencies.
- 39:47 Computer clocks operate on a limited resolution, creating potential conflicts when multiple events occur within the same tick window.
- 45:27 Clock drift causes hardware clocks to slowly desynchronize over time, making absolute time unreliable across distributed nodes.
- 45:27 Using network time protocols like NTP still leaves milliseconds of error, which is insufficient for high-frequency microsecond event ordering.
- 45:27 Instead of relying on real-time timestamps for ordering, systems should use logical sequence numbers and causality.
- 45:27 Optimistic locking and atomic batch writes help handle race conditions safely in event-sourced architectures.
Takeaways
- Never use real-time timestamps as a primary key or ordering mechanism for critical domain events.
- Recognize that server clocks naturally drift and cannot be perfectly synchronized across distributed infrastructure.
- Implement logical versioning and monotonic sequence numbers to guarantee correct event ordering.
Questions this talk answers
- Why do event-sourced systems suffer from out-of-order events when using timestamps?
- How can you accurately order events in a distributed system without relying on real-time clocks?
- What is the role of optimistic locking in resolving event concurrency conflicts?
Technologies
MySQL, PostgreSQL, Java
Tags
architecture, concurrency, databases, distributed systems, event sourcing