#PID<0.94.0>
node identifier
(relative to current node)
Slide 17
Slide 17 text
#PID<0.94.0>
node identifier
(relative to current node)
0 =a local process
Slide 18
Slide 18 text
#PID<0.94.0>
Process id
node identifier
(relative to current node)
Slide 19
Slide 19 text
How does it work?
Slide 20
Slide 20 text
Pid 1
Node A
Pid 2
Node B
Slide 21
Slide 21 text
Pid 1
Node A
Pid 2
Node B
TCP Connection
Slide 22
Slide 22 text
send(pid2, msg)
Pid 1
Node A
Pid 2
Node B
TCP Connection
Slide 23
Slide 23 text
send(pid2, msg)
Pid 1
Node A
Pid 2
Node B
destination_node = node(pid)
TCP Connection
Slide 24
Slide 24 text
send(pid2, msg)
Pid 1
Node A
Pid 2
Node B
destination_node = node(pid)
:erlang.term_to_binary(msg)
TCP Connection
Slide 25
Slide 25 text
send(pid2, msg)
Pid 1
Node A
Pid 2
Node B
destination_node = node(pid)
:erlang.term_to_binary(msg)
TCP Connection
Slide 26
Slide 26 text
send(pid2, msg)
Pid 1
Node A
Pid 2
Node B
destination_node = node(pid)
:erlang.term_to_binary(msg)
TCP Connection
:erlang.binary_to_term(encode)
Slide 27
Slide 27 text
send(pid2, msg)
Pid 1
Node A
receive msg
Pid 2
Node B
destination_node = node(pid)
:erlang.term_to_binary(msg)
TCP Connection
:erlang.binary_to_term(encode)
Slide 28
Slide 28 text
Distributed Systems?
Slide 29
Slide 29 text
Distributed Systems?
Solved!
Slide 30
Slide 30 text
Well, not exactly…
Slide 31
Slide 31 text
Difficulties
Slide 32
Slide 32 text
Node A
Node B
Slide 33
Slide 33 text
Node A
Node B
Node C
Slide 34
Slide 34 text
Node A
Node B
Node C
Node D
Slide 35
Slide 35 text
No content
Slide 36
Slide 36 text
A lot of messages
Slide 37
Slide 37 text
us-east-1
us-west-2
Slide 38
Slide 38 text
8 fallacies of
distributed computing
Slide 39
Slide 39 text
fallacies of distributed computing
1. The network is reliable
2. Latency is zero
3. Bandwidth is infinite
4. The network is secure
5. Topology doesn’t change
6. The is one administrator
7. Transport cost is zero
8. The network is homogenous
Slide 40
Slide 40 text
CAP THEOREM
Slide 41
Slide 41 text
CAP THEOREM
us-west-2
us-east-1
Slide 42
Slide 42 text
CAP THEOREM
us-west-2
us-east-1
Set X=5
Slide 43
Slide 43 text
CAP THEOREM
us-west-2
us-east-1
Set X=5
Read X
Slide 44
Slide 44 text
CAP THEOREM
us-west-2
us-east-1
Set X=5
Set X = 7
Slide 45
Slide 45 text
Consistency or Availability
(under network partition)
Phoenix
Request A
Phoenix
Request B
User Logged In
User Logged OUT
Slide 62
Slide 62 text
Phoenix
Request A
Phoenix
Request B
User Logged In
User Logged OUT
This Can arrive first
Slide 63
Slide 63 text
Unfortunately, things tend to work fine
locally
Slide 64
Slide 64 text
The Tools
Slide 65
Slide 65 text
:global
Slide 66
Slide 66 text
Pid 1
Node A Node B
Pid 2
Slide 67
Slide 67 text
Pid 1
Node A Node B
Pid 2
:global.register_name(“global”, self())
Slide 68
Slide 68 text
Pid 1
Node A Node B
Pid 2
:global.register_name(“global”, self())
Register PId1 as “global”
Slide 69
Slide 69 text
Pid 1
Node A Node B
Pid 2
:global.register_name(“global”, self())
Register PId1 as “global”
Sure
Slide 70
Slide 70 text
Pid 1
Node A Node B
Pid 2
:global.register_name(“global”, self())
Register PId1 as “global”
Sure
:global.whereis_name(“global”) = pid1
Slide 71
Slide 71 text
Pid 1
Node A Node B
Pid 2
:global.register_name(“global”, self()) :global.register_name(“global”, self())
?
Slide 72
Slide 72 text
(DEMO)
Slide 73
Slide 73 text
:global
• single process registration (if everything works OK)
• Favours availability over consistency
• Information stored locally (reading is fast)
• Registration is blocking (may be slow)
It will heal, but the state in inconsistent for
some time
Slide 88
Slide 88 text
What does it matter?
Slide 89
Slide 89 text
Node A
Pg2
Pg2
Pg2
Node B Node C
Slide 90
Slide 90 text
Node A
Pg2
Pg2
Pg2
Node B Node C
Phoenix Channels
Slide 91
Slide 91 text
Node A
Pg2
Pg2
Pg2
Node B Node C
Phoenix Presence
Slide 92
Slide 92 text
Node A
Pg2
Pg2
Pg2
Node B Node C
Phoenix Channels
Slide 93
Slide 93 text
:pg2
• Process groups
• Favours availability over consistency
• Information stored locally (reading is fast)
• Registration is blocking (may be slow)
Slide 94
Slide 94 text
Strongly consistent Solutions
Slide 95
Slide 95 text
Strongly consistent Solutions
• Consensus - Raft, Paxos, ZAB
• Two-phase commit/THree-phase commit (2PC/3PC)
• Read/Write quorums
• Single database as a source of truth
Slide 96
Slide 96 text
Summary
Slide 97
Slide 97 text
Distributed Systems
Slide 98
Slide 98 text
Well, not exactly…
Slide 99
Slide 99 text
Asynchronous messages
Distributed systems are all about
Slide 100
Slide 100 text
Really, there’s no magic
Slide 101
Slide 101 text
Just asynchronous messages between nodes
Slide 102
Slide 102 text
Just asynchronous messages between nodes
& node failures
Slide 103
Slide 103 text
Just asynchronous messages between nodes
& node failures
& Communication failures
Slide 104
Slide 104 text
Just asynchronous messages between nodes
& node failures
& Communication failures
& Network partitions