Network Partition and CAP therrem (Distributed Systems)
CAP
Consistency
read latest data
example:
write value 1 and sytem returns done, and read returns 1
Availability
always returns info
Partition tolerence
Network between nodes can be cut off
Still return something
CxA
sacrifice partition tolerence => can always talk to peer nodes
Can always return up to date info because peer is always available => consistent
Can always be available because peer is available => available
BUT, you will always be dealing with network paritions!
pick availability or consistency
PxC
Stop accepting trafic
Mitigation?
PxA
Risk of split brain
Algorithm to mitigate?
compensation
reconcilliation
ATM
withdrawal bounds check
allow overdraft by some number
amazon shopping cart
just take union (e.g. item deleted from version 1 re-appear when merged with version 2)
e.g. git
merge conflicts
Allow duplicate records
https://www.youtube.com/watch?v=gkg-FAEXIkY