distributed*systems* course*review* · distributed*systems* * course*review* rik*sarkar* *...

37
Distributed Systems Course Review Rik Sarkar University of Edinburgh Fall 2014 Distributed Systems, Edinburgh, 2014

Upload: others

Post on 26-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Distributed  Systems    

Course  Review  Rik  Sarkar  

 University  of  Edinburgh  

Fall  2014  

Distributed Systems, Edinburgh, 2014

Page 2: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Today:  Review  of  course  

•  Slight  updates  to  slides  –  Including  references  etc.  – Always  use  the  up  to  date  online  version  in  studying  

Distributed Systems, Edinburgh, 2014

Page 3: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Distributed  CompuHng  is  everywhere  

•  Web  browsing  •  MulHplayer  games  •  Digital  (Stock)  markets  •  CollaboraHve  ediHng  (Wikipedia,  reddit,  slashdot..)  •  Big  data  processing  (hadoop,  google  etc)  •  Networks  •  Mobile  and  sensor  systems  •  Ubiquitous  compuHng  •  Autonomous  vehicles  •  …  

Distributed Systems, Edinburgh, 2014

Ref: CDK

Page 4: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Reading  &  Books  

•  No  required  textbook  

•  Suggested  references:  –  [CDK]  Coulouris,  Dollimore,  Kindberg;  Distributed  Systems:  Concepts  and  Design  

•  4th  EdiHon:  hWp://www.cdk4.net/wo  •  5th  EdiHon:  hWp://www.cdk4.net/wo      

–  [VG]  Vijay  Garg;  Elements  of  Distributed  CompuHng  –  [NL]  Nancy  Lynch;  Distributed  Algorithms    –  [Wiki]  :  Wikipedia  

Distributed Systems, Edinburgh, 2014 4

Page 5: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Distributed  system  

•  CompuHng  in  a  graph  – Nodes:  computers  – Edges:  ConnecHons  

Distributed Systems, Edinburgh, 2014 5

Page 6: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

The  main  challenge:  

•  Knowledge  is  distributed    •  No  one  node  knows  everything  •  Different  nodes  have  different  views  (data)  of  the  system  

•  Yet,  nodes  are  expected  to  achieve  a  common  goal  

Distributed Systems, Edinburgh, 2014

Page 7: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Other  challenges  •  CommunicaHon  is  expensive  

– We  have  to  be  efficient:  Send  the  right  messages  –  CommunicaHon  is  usually  measured  in  asymptoHc  notaHon  

•  O,  Ω,  θ  •  Time  is  relaHve  

– Makes  hard  to  compare  events  •  There  may  be  failures:  nodes,  links  etc  •  Mobility  •  Security  •  Scalability:  There  can  be  many  nodes:  all  problems  become  more  challenging  

  Distributed Systems, Edinburgh, 2014

Page 8: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Simple  Algorithms  

Distributed Systems, Edinburgh, 2014

Page 9: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Example  

•  A  simple  distributed  computaHon:  – Each  node  has  stored  a  numeric  value  – Compute  the  total  of  the  numbers  

Server a b c d

v(d) V(c) +v(d)

v(b)+v(c)+v(d)

v(a)+v(b)+v(c)+v(d)

Cost: 4 messages

Distributed Systems, Edinburgh, 2014 9

Page 10: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Convergecast  •  Suppose  root  wants  to  know  sum  of  values  at  all  nodes  

•  It  sends  “compute”  message  to  all  children  

•  The  values  move  upward    •  Each  node  adds  values  from  all  children  and  its  own  value  

•  Sends  it  to  its  parent  

Distributed Systems, Edinburgh, 2014 10

root

Ref: NL

Page 11: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

CommunicaHon  with  all  nodes  

•  Flooding  •  ConstrucHng  a  (BFS  or  spanning)  tree  using  flooding  

Distributed Systems, Edinburgh, 2014

Page 12: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Minimum  spanning  trees  

•  Trees  of  smallest  total  edge  costs  •  Useful  in  communicaHon  •  Prim’s  &  Kruskal’s  algorithms  

–  [Ref:  Wiki]  •  GHS  algorithm  

–  [Ref:  NL]  

•  Maximum  independent  set  and  maximal  independent  sets  

Distributed Systems, Edinburgh, 2014

Page 13: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Time  

•  Time  &  ordering  of  events  are  important  •  Clocks  are  not  perfect  

– Drik  and  skew  

•  Simple  algorithms  to  unify  Hme  – ChrisHan’s  algorithm,  berkeley,  NTP  etc..  

•  Not  in  exam:  GPS,  special  relaHvity  

Distributed Systems, Edinburgh, 2014

Ref: CDK

Page 14: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Logical  Hme  

•  For  ordering  of  events  without  using  clocks  – Ref:  CDK  &  VG  

Distributed Systems, Edinburgh, 2014

Page 15: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Happened  before  

•  a⟶b  :  a  happened  before  b  –  If  a  and  b  are  successive  events  in  same  process  then  a⟶b  

– Send  before  receive  •  If  a  :  “send”  event  of  message  m  •  And  b  :  “receive”  event  of  message  m  •  Then  a⟶b  

– TransiHve:  a⟶b  and  b⟶c  ⟹a⟶c  

Distributed Systems, Edinburgh, 2014 15

Page 16: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Distributed Systems, Edinburgh, 2014 16

e1 e2

e3

e5 e4

p1

p2

p3

Page 17: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

•  Events  without  a  happened  before  relaHon  are  “concurrent”  

•  e1⟶e2,  e3⟶e4,e1⟶e5,  e5||e2    

Distributed Systems, Edinburgh, 2014 17

e1 e2

e3

e5 e4

p1

p2

p3

Page 18: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Happened  before  &  causal  order  

•  Happened  before  ==  could  have  caused/influenced  

•  Preserves  causal  relaHons  •  Implies  a  parHal  order  

–  Implies  Hme  ordering  between  certain  pairs  of  events  

– Does  not  imply  anything  about  ordering  between  concurrent  events  

Distributed Systems, Edinburgh, 2014 18

Page 19: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Logical  clocks  

•  Idea:  Use  a  counter  at  each  process  •  Increment  aker  each  event    •  It  counts  the  states  of  the  process  •  Each  event  has  an  associated  Hme:  The  count  of  the  state  when  the  event  happened  

Distributed Systems, Edinburgh, 2014 19

Page 20: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Lamport  clocks  

•  Keep  a  logical  clock  (counter)  •  Send  it  with  every  message  •  On  receiving  a  message,  set  own  clock  to      max({own  counter,  message  counter})  +  1  

•  For  any  event  e,  write  c(e)  for  the  logical  Hme  •  Property:    

–  If  a⟶b,  then  c(a)  <  c(b)  –  If  a  ||  b,  then  no  guarantees  

Distributed Systems, Edinburgh, 2014 20

Page 21: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Lamport  clocks:  example  

Distributed Systems, Edinburgh, 2014 21

e1

e3

e5

e4

p1

p2

p3

2 3

2 1 3 6

9 10 4 5

Page 22: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Concurrency  and  lamport  clocks  

•  If  e1⟶e2  – Then  no  lamport  clock  C  exists  with  C(e1)==  C(e2)  

Distributed Systems, Edinburgh, 2014 22

Page 23: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Concurrency  and  lamport  clocks  

•  If  e1⟶e2  – Then  no  lamport  clock  C  exists  with  C(e1)==  C(e2)  

•  If  e1||e2,  then  there  exists  a  lamport  clock  C  such  that  C(e1)==  C(e2)  

Distributed Systems, Edinburgh, 2014 23

Page 24: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

The  purpose  of  Lamport  clocks  

•  If  a⟶b,  then  c(a)  <  c(b)  

•  If  we  order  all  events  by  their  lamport  clock  Hmes  – We  get  a  parHal  order,  since  some  events  have  same  Hme  

– The  parHal  order  saHsfies  “causal  relaHons”  

Distributed Systems, Edinburgh, 2014 24

Page 25: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

ModificaHons  

•  Basic  lamport  clocks  can  have  same  Hme  for  2  events  in  different  processes  – We  can  break  these  Hes  by  process  id  –  Then  any  2  events  are  ordered:  total  order  

•  Vector  clocks  –  Lamport  clock  ordering  do  not  imply  causal  relaHon  –  Vector  clocks  can  be  used  to  get  perfect  knowledge  of  causality  

Distributed Systems, Edinburgh, 2014

Page 26: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Distributed  snapshots  

•  Consistent  cuts  – Snapshot  algorithms  record  consistent  states  

•  Single  snapshots  are  good  for  detecHng  stable  predicates  

•  Non-­‐stable  predicates  – Possibly,  definitely  etc  – Require  checking  all  consistent  cuts  

Distributed Systems, Edinburgh, 2014

Ref: CDK

Page 27: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Mutual  Exclusion  

•  ProperHes:  Safety,  Liveness,  Fairness  •  Central  server  •  Token  ring  •  Lamport  •  Ricart  &  Agrawala  •  Maekawa’s  quorum  system  with  grids  

Distributed Systems, Edinburgh, 2014

Ref: CDK, VG

Page 28: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

CommunicaHon  and  models  •  Medium  access  &  broadcast  •  RouHng  &  point  to  point  communicaHon  •  Transport:  ordering  and  congesHon  control  •  Each  layer  of  a  network  solves  a  different  distributed  problem  

•  Synchronous  and  asynchronous  communicaHon  –  CommunicaHon  in  rounds  –  Easy  to  implement  when  message  transmission  Hme  is  bounded  

Distributed Systems, Edinburgh, 2014

Page 29: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Failure  detectors  

•  With  bounded  message  delays  •  With  probabiliHes  

Distributed Systems, Edinburgh, 2014

Ref: CDK

Page 30: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Leader  elecHon  

•  Find  the  highest  id  node  •  Convergecast  •  Ring  search:  chang  and  roberts  •  Ring  search:  ExponenHally  growing:  Hirshberg  Sinclair  

•  Bully  algorithm  

Distributed Systems, Edinburgh, 2014

Ref: NL & CDK

Page 31: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

MulHcast  

•  Usually  used  in  local/small  networks  with  broadcast  

•  When  used  in  slightly  larger  networks  •  Can  we  ensure  that  messages  are  delivered  reliably  to  all  nodes  in  group?  

•  We  use  basic  mulHcast  as  a  building  block  for  reliable  mulHcast  

•  Possible  guarantees:  FIFO,  causality,  total  order  

Distributed Systems, Edinburgh, 2014

Page 32: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

TerminaHon  and  OS  

•  TerminaHon  detecHon  – Weight  throwing  – Dijkstra  Scholten  

•  Ref:  Wiki,  VG  

•  OS  – Networked  OS  – Distributed  OS  – VirtualizaHon  

•  Ref:  CDK  

Distributed Systems, Edinburgh, 2014

Page 33: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Peer  to  Peer  

•  The  challenges  and  benefits  •  Examples:  Internet,  napster,  gnutella,  chord,  skype,  biwrrent,  SETI@home  

•  DHT  

Distributed Systems, Edinburgh, 2014

Ref: CDK, Wiki

Page 34: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

LocalizaHon  &  LocaHon  based  rouHng  

•  Ref:  Slides  only  – You  can  find  more  material  on  internet,  wiki,  other  course  slides  

•  Not  in  exam:  MDS,  lower  and  upper  bounds  on  complexity  of  greedy  and  face  rouHng,  cross  link  detecHon  protocol,  Rumor  rouHng  

Distributed Systems, Edinburgh, 2014

Page 35: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Coloring  and  MIS  

•  Assignment  of  non-­‐interfering  communicaHon  channels  

•  Finding  largest  sets  of  non-­‐interfering  nodes  •  Randomized  algorithm  can  be  much  more  efficient  

•  Ref:  given  in  slides  

Distributed Systems, Edinburgh, 2014

Page 36: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Security  

•  Main  defense  is  EncrypHon  •  Public  key  encrypHon,  RSA  

Distributed Systems, Edinburgh, 2014

Page 37: Distributed*Systems* Course*Review* · Distributed*Systems* * Course*Review* Rik*Sarkar* * University*of*Edinburgh* Fall*2014* Distributed Systems, Edinburgh, 2014

Course  MaWer    

•  Assignment  •  Course  •  Material    

Distributed Systems, Edinburgh, 2014