SlideShare a Scribd company logo
1 of 38
A SHORT STORY ABOUT TIME
INTRODUCTION
Bartosz Sypytkowski
▪ @Horusiath
▪ b.sypytkowski@gmail.com
▪ bartoszsypytkowski.com
 Timekeeping in distributed systems
 UTC
 How clocks work
 System time
 NTP
 Logical time
AGENDA
Timekeeping
in
distributed
systems
Node 1
Bob Joe
SET X = 2SET X = 1
Timekeeping
in
distributed
systems
Node 1
Node 2
Bob Joe
SET X = 2SET X = 1
“Time is not a thing, it’s a subjective
experience.”
CLOCKS
PENDULUM
CLOCK
• Frequency: < 1Hz
• Precision: ~1 sec.
DIGITAL CLOCK • Frequency: 50Hz – 60Hz
• Precision: 16-20ms
QUARTZ
CLOCK
• Frequency: 32kHz – 2MHz
• Precision: 0.5µs - 31µs
ATOMIC CLOCK • Frequency (Cessium-133):
9,192,631,770Hz
• Precision: ~0.1ns
GPS CLOCK
SYNC
UNIX TIME
 Number of seconds since epoch (1970/01/01)
 It has exactly 86 400s per day…
• Day does not take 24h…
• … it’s not even a constant.
A TRUTH ABOUT DAY
UTC
ATOMIC TIME
BASED ON ATOMIC CLOCK
SOLAR/ASTRONOMICAL TIME
BASED ON EARTH ROTATION
UTC
A COMPROMISE BASED ON ATOMIC
TIME IRREGULARLY ADJUSTED TO
SOLAR TIME
LEAP
SECONDS
UTC
23:59:58
23:59:59
23:59:60
00:00:00
00:00:01
UNIX
23:59:58
23:59:59
23:59:59
00:00:00
00:00:01
CONSEQUENCES OF
NON-MONOTONIC
TIME
Node 1
Node 2
Bob Joe
ts = 60
SET X = 2SET X = 1
ts = 20
LEAP SECONDS IN PRACTICE
NETWORK
TIME
PROTOCOL
NETWORK
TIME
PROTOCOL
1. Skew – speedup/slowdown clock tick
rate
2. Step – set a new value when difference
is too big (128ms)
NTP PROBLEMS
▪ Stepping interferes with happen-before
relationships.
▪ It’s slow.
▪ It assumes, that network is symmetric.
PRECISION TIME
PROTOCOL
▪ Available in Windows Server 2019
(opt-in)
▪ Takes into account a latency per
each network device
OS TIME
API
WINDOWS
wall-clock time
LINUX
wall-clock time
WINDOWS
monotonic time
LINUX
monotonic time
clock_gettime(CLOCK_REALTIME)
clock_gettime(CLOCK_MONOTONIC)QueryPerformanceCounter(&time)
GetSystemTimePreciseAsFileTime(&date)
“In transactions, timekeeping is more
about order of operations than actual
time.”
SEQUENCERS
Set X = 1 ts = 1
Set Y = 2 ts = 2
Set X = 3 ts = 3
Delete Y ts = 4
Set Y = 1 ts = 5
Delete X ts = 6
Monotonically incrementing counter
timeline
Node A
DOTS
Set X = 1 A:1
Set X = 3 A:2
Set Y = 1 A:3
Delete X A:4
timeline
Node A
Set Y = 2 B:1
Delete Y B:2
timeline
Node B
VECTOR
CLOCKS
Set X = 1
Set X = 3
Set Y = 1
Delete X
Node A
Set Y = 2
Delete Y
Node B
A 1
A 1
B 1
A 2
B 1 A 2
B 2
A 3
B 2
A 4
B 2
COMPAR
ING
VECTOR
CLOCKS
PARTIAL
ORDERING
Equals Greater than
Less than Concurrent
A 2
B 3
C 1
A 2
B 3
C 1
A 2
B 3
C 2
A 2
B 3
C 1
A 2
B 2
C 1
A 2
B 3
C 1
A 2
B 3
C 2
A 2
B 2
C 1
COMPAR
ING
VECTOR
CLOCKS
RESOLVING
CONCURRENT
UPDATES
Node 1
Node 2
Bob Joe
t1
SET X = 2SET X = 1
t2
COMPAR
ING
VECTOR
CLOCKS
RESOLVING
CONCURRENT
UPDATES
Node 1
Node 2
Bob Joe
t1
SET X = 2SET X = 1
t2
max (t1, t2)
max (t1, t2)
LAST
WRITE
WINS
MAX (2018-09-15T15:53:00, 2019-01-12T17:47:13)
=
2019-01-12T17:47:13
VECTOR
CLOCK
MERGE
MAX ( , )
=
A 1
B 3
A 2
B 1
C 1
A 2
B 3
C 1
Overhead:
Nr. of nodes * (Key size + seq. nr.)
Examples:
3 × (4 + 8) = 36 bytes
10 × (16 + 8) = 240 bytes
DATETIME / SEQ. NR.
Overhead:
8 bytes
VECTOR CLOCKS
DOTTED
VERSION
VECTORS
DOTTED
VERSION
VECTORS
REPRESENTATION
D 4
C 5
B 7
A 5
D 8
C 10
C 11
A 9
version vector dot cloud
+
HOW TO DETERMINE “SEEN BY ALL”?
DOT VECTOR
CLOCK
???
MATRIX
CLOCKS
2 2 1
2 3 1
2 2 2
A
B
C
A B C
Observers
Observed
 Keeping time in real systems: https://www.youtube.com/watch?v=BRvj8PykSc4
 Windows plans for leap seconds: https://blogs.technet.microsoft.com/networking/2018/07/18/top10-ws2019-hatime/
 Dotted version vectors: http://basho.com/posts/technical/vector-clocks-revisited-part-2-dotted-version-vectors/
REFERENCES
THANK YOU

More Related Content

Similar to Short story of time

University of manchester mathematical formula tables
University of manchester mathematical formula tablesUniversity of manchester mathematical formula tables
University of manchester mathematical formula tables
Gaurav Vasani
 
Quantum factorization.pdf
Quantum factorization.pdfQuantum factorization.pdf
Quantum factorization.pdf
ssuser8b461f
 

Similar to Short story of time (20)

Multiband Transceivers - [Chapter 1]
Multiband Transceivers - [Chapter 1] Multiband Transceivers - [Chapter 1]
Multiband Transceivers - [Chapter 1]
 
07_Digital timing_&_Pipelining.ppt
07_Digital timing_&_Pipelining.ppt07_Digital timing_&_Pipelining.ppt
07_Digital timing_&_Pipelining.ppt
 
Introduction of GPS BPSK-R and BOC
Introduction of GPS BPSK-R and BOCIntroduction of GPS BPSK-R and BOC
Introduction of GPS BPSK-R and BOC
 
Lecture1
Lecture1Lecture1
Lecture1
 
Note and assignment mis3 5.3
Note and assignment mis3 5.3Note and assignment mis3 5.3
Note and assignment mis3 5.3
 
Chapter1 - Signal and System
Chapter1 - Signal and SystemChapter1 - Signal and System
Chapter1 - Signal and System
 
Calculus Early Transcendentals 10th Edition Anton Solutions Manual
Calculus Early Transcendentals 10th Edition Anton Solutions ManualCalculus Early Transcendentals 10th Edition Anton Solutions Manual
Calculus Early Transcendentals 10th Edition Anton Solutions Manual
 
Trigonometry 10th edition larson solutions manual
Trigonometry 10th edition larson solutions manualTrigonometry 10th edition larson solutions manual
Trigonometry 10th edition larson solutions manual
 
Trigonometry 10th Edition Larson Solutions Manual
Trigonometry 10th Edition Larson Solutions ManualTrigonometry 10th Edition Larson Solutions Manual
Trigonometry 10th Edition Larson Solutions Manual
 
Clase 16 dsp
Clase 16 dspClase 16 dsp
Clase 16 dsp
 
Frequency modulation
Frequency modulationFrequency modulation
Frequency modulation
 
Solutions Manual for Calculus Early Transcendentals 10th Edition by Anton
Solutions Manual for Calculus Early Transcendentals 10th Edition by AntonSolutions Manual for Calculus Early Transcendentals 10th Edition by Anton
Solutions Manual for Calculus Early Transcendentals 10th Edition by Anton
 
University of manchester mathematical formula tables
University of manchester mathematical formula tablesUniversity of manchester mathematical formula tables
University of manchester mathematical formula tables
 
Oscillatorsppt
OscillatorspptOscillatorsppt
Oscillatorsppt
 
2018 MUMS Fall Course - Mathematical surrogate and reduced-order models - Ral...
2018 MUMS Fall Course - Mathematical surrogate and reduced-order models - Ral...2018 MUMS Fall Course - Mathematical surrogate and reduced-order models - Ral...
2018 MUMS Fall Course - Mathematical surrogate and reduced-order models - Ral...
 
Digital data transmission
Digital data transmissionDigital data transmission
Digital data transmission
 
G e hay's
G e hay'sG e hay's
G e hay's
 
Quantum factorization.pdf
Quantum factorization.pdfQuantum factorization.pdf
Quantum factorization.pdf
 
射頻電子 - [第二章] 傳輸線理論
射頻電子 - [第二章] 傳輸線理論射頻電子 - [第二章] 傳輸線理論
射頻電子 - [第二章] 傳輸線理論
 
Dsp class 2
Dsp class 2Dsp class 2
Dsp class 2
 

More from Bartosz Sypytkowski

More from Bartosz Sypytkowski (14)

Postgres indexes: how to make them work for your application
Postgres indexes: how to make them work for your applicationPostgres indexes: how to make them work for your application
Postgres indexes: how to make them work for your application
 
How do databases perform live backups and point-in-time recovery
How do databases perform live backups and point-in-time recoveryHow do databases perform live backups and point-in-time recovery
How do databases perform live backups and point-in-time recovery
 
Scaling connections in peer-to-peer applications
Scaling connections in peer-to-peer applicationsScaling connections in peer-to-peer applications
Scaling connections in peer-to-peer applications
 
Rich collaborative data structures for everyone
Rich collaborative data structures for everyoneRich collaborative data structures for everyone
Rich collaborative data structures for everyone
 
Postgres indexes
Postgres indexesPostgres indexes
Postgres indexes
 
Behind modern concurrency primitives
Behind modern concurrency primitivesBehind modern concurrency primitives
Behind modern concurrency primitives
 
Collaborative eventsourcing
Collaborative eventsourcingCollaborative eventsourcing
Collaborative eventsourcing
 
Behind modern concurrency primitives
Behind modern concurrency primitivesBehind modern concurrency primitives
Behind modern concurrency primitives
 
Living in eventually consistent reality
Living in eventually consistent realityLiving in eventually consistent reality
Living in eventually consistent reality
 
Virtual machines - how they work
Virtual machines - how they workVirtual machines - how they work
Virtual machines - how they work
 
Akka.NET streams and reactive streams
Akka.NET streams and reactive streamsAkka.NET streams and reactive streams
Akka.NET streams and reactive streams
 
Collaborative text editing
Collaborative text editingCollaborative text editing
Collaborative text editing
 
The last mile from db to disk
The last mile from db to diskThe last mile from db to disk
The last mile from db to disk
 
GraphQL - an elegant weapon... for more civilized age
GraphQL - an elegant weapon... for more civilized ageGraphQL - an elegant weapon... for more civilized age
GraphQL - an elegant weapon... for more civilized age
 

Recently uploaded

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Recently uploaded (20)

%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 

Short story of time

Editor's Notes

  1. Fun fact: this issue didn’t happened in Google, because they have used so called “leap second smearing” – when they knew that leap second is getting closer, they started to drift their atomic clocks on purpose to slowly compensate for that leap second. The problem is that this is not official way of doing things, so Google’s internal reference clocks were not inline will any other reference clocks for some time. Sometimes providers (like Amazon) officially announce leap seconds incoming. NTP also can send a packet informing about incoming leap second.