Study notesWeek 2: Distributed Systems Fundamentals
Week 2

Distributed Systems Fundamentals

Outcomes

What You Can Do By The End

The root problem

No Shared Memory, No Shared Clock

False beliefs

The Eight Fallacies

Networks

What A Message Can Do

Protocols

UDP, TCP And Repeatable Requests

Physics

Latency Has A Floor

0224567900.53080Same data centerSame continentAcross an ocean
distance_km = 5000
speed_km_per_s = 200000   # light in fiber, approx
one_way_ms = distance_km / speed_km_per_s * 1000
print(one_way_ms, one_way_ms * 2)
Two different limits

Latency Versus Bandwidth

Failures

Partial Failure

Failures

Network Partitions

[A] [B]   X   [C] [D]
 group 1   cut   group 2
Clocks

Time And Order

Copies

Replication And Consistency

Brewer 2000, Gilbert and Lynch 2002

The CAP Theorem

Applying CAP

CP Or AP: Choosing By Cost

ChoiceDuring a partitionGood fit
CPRefuse some requestsBalances, bookings
APAnswer, maybe staleFeeds, likes, carts
Simulation

Eventual Consistency In 12 Lines

a = {'v': 'red',  't': 1}
b = {'v': 'blue', 't': 2}

def merge(x, y):
    return x if x['t'] >= y['t'] else y

winner = merge(a, b)
a, b = dict(winner), dict(winner)
print(a, b)
# both replicas now hold {'v': 'blue', 't': 2}
Summary

Recap

Week 3

Next Week

Your turn

Questions And Exercise