Dealing with Time and Clocks in Code
summary
Hardware clocks like a cheap Adafruit RTC typically drift ~5 seconds/month, VMs can be swapped out so their clocks jump, and network offsets create system precisions of seconds so ordering is imperfect — a token can appear generated 278 ms in the future and be rejected. Use NTP to regain millisecond accuracy, store timestamps as UTC and format with ISO 8601, avoid custom time math, and accept that distributed time is fuzzy rather than trying to build a perfect clock.
AI-written summary · about
chapters (13)
- 0:00Introduction and speaker background
- 1:52Time problems in distributed systems
- 3:16Hardware clock drift and precision
- 7:10Why server clocks drift
- 9:40NTP and time synchronization
- 13:14Debugging the token timestamp bug
- 14:43Human vs. machine time precision
- 16:37ISO 8601 timestamps
- 18:24Time zones are for humans
- 23:25Leap years and timestamp bugs
- 25:13Don’t code with time yourself
- 26:18Use UTC everywhere
- 29:12Summary and key takeaways
