Академический Документы
Профессиональный Документы
Культура Документы
NTP b c
Server
Laptop
a d
Time
1. Internal Synchronization:
– Peer systems synchronize among
themselves
– Bound
• If the synchronization scheme has a bound D
– (i.e. two clocks will have max D skew)
• Then all clocks will agree within D.
MISM 95-702 Distributed Systems 15
Synchronization
2. External Synchronization
– Systems all synchronize with a more
authoritative external clock
– I.e. UTC (Coordinated Universal Time)
– Bound:
• Each clock is accurate to UTC within D
p2 Physical
c d time
m2
p3
e f
p1
a b m1
p2 Physical
c d time
m2
p3
e f
p1
a b m1
p2 Physical
c d time
m2
p3
e f
p1
a b m1
p2 Physical
c d time
m2
p3
e f
events happen at
p Physical
the same instance 2
c d m
time
2
in time.
p3
– This is unknowable in e f
a distributed system.
• e is logically concurrent to all of a, b, m1, c, d, m2
• f is not logically concurrent to any of the events
3 4
p2 Physical
time
c d
m2
1 5
p3
e f
3 4
p2 Physical
time
c d
m2
1 5
p3
e g f
3 4
p2 Physical
time
c d
m2
1 5
p3
e g f
3 4
Physical
p2
c d time
m2
1 2 5
p3
e g f Is this still useful?
No. - It gives a partial ordering.
- d->f implies L(d) < L(f) - The Lamport Clocks of two
causally-related events
- L(g) < L(d) does not imply g->d
will be ordered
- In this system design, d and g
are not causally related.
- It does not matter if g->d
MISM 95-702 OCT 34
Total & Causal Ordering
• Lamport Clocks can be used to coordinate the ordering of
distributed events so that each process executes events in
the same order (e.g. updating a database)
• Vector clocks are extensions to Lamport's work:
– Each process is assigned a process-index
– Messages between processes carry a vector of process-index and
Lamport-clock with them
• E.g. Dynamo, Amazon.com’s highly available key-value
storage system, uses vector clocks.
– See: http://s3.amazonaws.com/AllThingsDistributed/sosp/amazon-dynamo-sosp2007.pdf Section 4.4
p2 Physical
c d time
m2
p3
e f
Source: Distributed Computing: Principles, Algorithms, and Systems By Ajay D. Kshemkalyani, Mukesh Singha
MISM 95-702 OCT 43
C12
P1 P2
C21
Y B R Y B R
P1 P2
C21 C12
Total Total
Y B R
P1 P1
C21
C12
C31
TOTAL
C13
C31
C21
P3 P2
C32
C23
Y B R Y B R
P3 P2
C13 C12
C23 C32
TOTAL TOTAL
PITplayer1
Queue: jms/PITplayer1
Queue: jms/PITplayer2
PITplayer3 PITplayer2
Queue: jms/PITplayer3
In the trading simulation, the channels are implemented as JMS Queues.
This meets the Chandy & Lamport snapshot algorithm assumption that
there are channels from each player to every other player, and that the
channels are First-In-First-Out.
All players are implemented as Message Drive Beans (aka Queue
Listeners)
Using State for Debugging
• A: waitreply(B) • How could info
• B: like this be
• C: waitreply(A) collected?
• D: waitreply(F)
• E: waitreply(F) • What does it say
about the state of
• F: waitreply(G) the system?
• G: waitreply(D)