CAP Theorem

6539ae86c7d8ddec66f3928beddad569?s=47 Nate Smith
November 14, 2012

CAP Theorem

A run through of the CAP theorem using a Dynamo-based example. Talk given to my coworkers @ theScore.

6539ae86c7d8ddec66f3928beddad569?s=128

Nate Smith

November 14, 2012
Tweet

Transcript

  1. RIAK

  2. A BRIEF DIVERSION...

  3. A BRIEF DIVERSION...

  4. DISTRIBUTED SYSTEMS

  5. CAP THEOREM

  6. CONSISTENCY AVAILABILITY PARTITION TOLERANCE

  7. None
  8. None
  9. CONSISTENCY

  10. A B chunky: ‘bacon’ chunky: ‘bacon’

  11. A B chunky: ‘bacon’ chunky: ‘bacon’ chunky: ‘chicken’

  12. A B chunky: ‘chicken’ chunky: ‘bacon’ chunky: ‘chicken’

  13. A B chunky: ‘chicken’ chunky: ‘bacon’ chunky: ‘chicken’

  14. A B chunky: ‘chicken’ chunky: ‘chicken’ chunky: ‘chicken’

  15. A B chunky: ‘chicken’ chunky: ‘chicken’ chunky: ‘chicken’

  16. A B chunky: ‘chicken’ chunky: ‘bacon’ chunky: ‘chicken’

  17. A B chunky: ‘chicken’ chunky: ‘bacon’ chunky: ‘chicken’ ?

  18. A B chunky: ‘chicken’ chunky: ‘bacon’ chunky: ‘chicken’ chunky: ‘bacon’

  19. A B chunky: ‘chicken’ chunky: ‘bacon’ chunky: ‘chicken’ chunky: ‘chicken’

  20. “ATOMIC, OR LINEARIZABLE, CONSISTENCY IS THE CONDITION EXPECTED BY MOST

    WEB SERVICES TODAY. UNDER THIS CONSISTENCY GUARANTEE, THERE MUST EXIST A TOTAL ORDER ON ALL OPERATIONS SUCH THAT EACH OPERATION LOOKS AS IF IT WERE COMPLETED AT A SINGLE INSTANT. THIS IS EQUIVALENT TO REQUIRING REQUESTS OF THE DISTRIBUTED SHARED MEMORY TO ACT AS IF THEY WERE EXECUTING ON A SINGLE NODE, RESPONDING TO OPERATIONS ONE AT A TIME.”
  21. “ATOMIC, OR LINEARIZABLE, CONSISTENCY IS THE CONDITION EXPECTED BY MOST

    WEB SERVICES TODAY. UNDER THIS CONSISTENCY GUARANTEE, THERE MUST EXIST A TOTAL ORDER ON ALL OPERATIONS SUCH THAT EACH OPERATION LOOKS AS IF IT WERE COMPLETED AT A SINGLE INSTANT. THIS IS EQUIVALENT TO REQUIRING REQUESTS OF THE DISTRIBUTED SHARED MEMORY TO ACT AS IF THEY WERE EXECUTING ON A SINGLE NODE, RESPONDING TO OPERATIONS ONE AT A TIME.”
  22. AVAILABILITY

  23. A B C D E

  24. A B C D E

  25. “FOR A DISTRIBUTED SYSTEM TO BE CONTINUOUSLY AVAILABLE, EVERY REQUEST

    RECEIVED BY A NON-FAILING NODE IN THE SYSTEM MUST RESULT IN A RESPONSE. THAT IS, ANY ALGORITHM USED BY THE SERVICE MUST EVENTUALLY TERMINATE … [WHEN] QUALIFIED BY THE NEED FOR PARTITION TOLERANCE, THIS CAN BE SEEN AS A STRONG DEFINITION OF AVAILABILITY: EVEN WHEN SEVERE NETWORK FAILURES OCCUR, EVERY REQUEST MUST TERMINATE.”
  26. “FOR A DISTRIBUTED SYSTEM TO BE CONTINUOUSLY AVAILABLE, EVERY REQUEST

    RECEIVED BY A NON-FAILING NODE IN THE SYSTEM MUST RESULT IN A RESPONSE. THAT IS, ANY ALGORITHM USED BY THE SERVICE MUST EVENTUALLY TERMINATE … [WHEN] QUALIFIED BY THE NEED FOR PARTITION TOLERANCE, THIS CAN BE SEEN AS A STRONG DEFINITION OF AVAILABILITY: EVEN WHEN SEVERE NETWORK FAILURES OCCUR, EVERY REQUEST MUST TERMINATE.”
  27. PARTITION TOLERANCE

  28. A B C D E

  29. A B C D E

  30. “IN ORDER TO MODEL PARTITION TOLERANCE, THE NETWORK WILL BE

    ALLOWED TO LOSE ARBITRARILY MANY MESSAGES SENT FROM ONE NODE TO ANOTHER. WHEN A NETWORK IS PARTITIONED, ALL MESSAGES SENT FROM NODES IN ONE COMPONENT OF THE PARTITION TO NODES IN ANOTHER COMPONENT ARE LOST. (AND ANY PATTERN OF MESSAGE LOSS CAN BE MODELED AS A TEMPORARY PARTITION SEPARATING THE COMMUNICATING NODES AT THE EXACT INSTANT THE MESSAGE IS LOST).”
  31. “IN ORDER TO MODEL PARTITION TOLERANCE, THE NETWORK WILL BE

    ALLOWED TO LOSE ARBITRARILY MANY MESSAGES SENT FROM ONE NODE TO ANOTHER. WHEN A NETWORK IS PARTITIONED, ALL MESSAGES SENT FROM NODES IN ONE COMPONENT OF THE PARTITION TO NODES IN ANOTHER COMPONENT ARE LOST. (AND ANY PATTERN OF MESSAGE LOSS CAN BE MODELED AS A TEMPORARY PARTITION SEPARATING THE COMMUNICATING NODES AT THE EXACT INSTANT THE MESSAGE IS LOST).”
  32. None
  33. ?

  34. None
  35. ?

  36. A B C D E

  37. A B C D E

  38. A B C D E

  39. A B C D E

  40. A B C D E

  41. A B C D E

  42. A B C D E

  43. A B C D E

  44. WRITES

  45. A B C D E

  46. A B C D E

  47. B A C D E

  48. B A C D E

  49. B A C D E

  50. B A C D E

  51. READS

  52. A B C D E

  53. B A C D E

  54. B A C D E

  55. B A C D E

  56. ...

  57. A B C D E

  58. MAJORITY

  59. A B C D E

  60. A B C D E

  61. CONSISTENT

  62. N W R REPLICAS WRITE SUCCESS READ SUCCESS

  63. (N/2) + 1

  64. R+W > N

  65. FAIL

  66. A B C D E

  67. A B C D E

  68. YOU GET THE CHOICE

  69. R+W <= N

  70. A B C D E

  71. W=N, R=1

  72. R=N, W=1

  73. TUNE FOR C OR A

  74. CAN’T HAVE BOTH

  75. CAN’T REALLY DO MUCH MORE ABOUT P

  76. IT’S A BUSINESS DECISION

  77. None
  78. None
  79. None