Data corrupting architectures we know and love - VelocityConf San Jose 2019

Data corrupting architectures we know and love - VelocityConf San Jose 2019

There’s an old distributed systems adage, “You can have a second computer when you learn how to use the first one.” When it comes to data-access patterns, most of our favorite patterns are unsafe on a single computer. Most of our applications assume a concurrency model where all access is serialized. What happens when that mental model meets distributed data?

Sean Allen reviews data race and corruption problems that exist on single-machine systems and shows how we’ve transferred many of those patterns over to distributed systems and distributed state. You’ll learn the basics of data races, deadlocks, and problems in even the simplest of our concurrent data access patterns and how our existing scaling patterns replicate the same issues across multiple machines, increasing the potential problems, as well as designs that can alleviate them.

3c53e91d2a6ceb1b7f202d709f638b1b?s=128

Sean T Allen

June 12, 2019
Tweet

Transcript

  1. WE KNOW AND LOVE DATA CORRUPTING ARCHITECTURES

  2. VP OF ENGINEERING @ WALLAROO LABS MEMBER OF THE PONY

    CORE TEAM AUTHOR OF “STORM APPLIED” SPOILED BOSTON SPORTS FAN @SEANTALLEN @WALLAROOLABS @PONYLANG @NHLBRUINS SEAN T. ALLEN
  3. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE A TALK ABOUT

    SCALING
  4. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE A TALK ABOUT

    “STATELESS”
  5. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE THIS AN OVERVIEW

    TALK
  6. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE TODAY’S TOPICS INCLUDE…

    ▸ Data corruption ▸ Concurrency ▸ Data races ▸ Shared values ▸ Atomic operations
  7. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE GITHUB.COM/SEANTALLEN/DATA- CORRUPTING-ARCHITECTURES

  8. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE GENERALIZATIONS AHEAD

  9. OUR MOST POPULAR ARCHITECTURES CAN BE TRACED TO WEB APPPLICATIONS.

    Sean T. Allen DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE
  10. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE DATABASE WEB APP

  11. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE A BIT MORE

    DETAILED… REQUEST to the APPLICATION on to the DATABASE back to the APPLICATION and out as a RESPONSE
  12. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE WE COULD GET

    MORE DETAILED STILL… REQUEST to the APPLICATION on to the DATABASE back to the APPLICATION and out as a RESPONSE (WEB BROWSER) to the (WEB SERVER + DEVELOPER CODE) on to the DATABASE back to the (WEB SERVER + DEVELOPER CODE) and out as a (WEB BROWSER)
  13. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE OUR SIMPLE WEB

    APP IS A DISTRIBUTED SYSTEM
  14. DISTRIBUTED SYSTEMS AREN’T HARD. THEY’RE EASY*. Sean T. Allen DATA

    CORRUPTING ARCHITECTURES WE KNOW AND LOVE * sometimes
  15. DISTRIBUTED SYSTEMS AREN’T HARD. THEY’RE EASY*. CONCURRENCY IS THE HARD

    PART. Sean T. Allen DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE * sometimes
  16. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE SOME JUSTIFICATION AHEAD

  17. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE DATABASE WEB APP

  18. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE DATABASE WEB APP

  19. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE DATABASE WEB APP

  20. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE AN EXAMPLE APPLICATION

  21. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE THE PAGES SERVED

    COUNTER ‣ Read current value from the database ‣ Add one to update it ‣ Write new value to the database ‣ Return new value to the user
  22. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE THE PAGES SERVED

    COUNTER ‣ Read current value from the database ‣ Add one to update it ‣ Write new value to the database ‣ Return original value to the user SPOT THE DATA CORRUPTION?
  23. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE THE PAGES SERVED

    COUNTER ‣ Read current value from the database ‣ Add one to update it ‣ Write new value to the database ‣ Return new value to the user
  24. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE THE PAGES SERVED

    COUNTER ‣ Read current value from the database ‣ Add one to update it ‣ Write new value to the database ‣ Return original value to the user LET’S ADD SOME CONCURRENCY
  25. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE THE PAGES SERVED

    COUNTER ‣ Read current value from the database ‣ Add one to update it ‣ Write new value to the database ‣ Return new value to the user ‣ Read current value from the database ‣ Add one to update it ‣ Write new value to the database ‣ Return new value to the user
  26. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE THE PAGES SERVED

    COUNTER ‣ Read current value from the database ‣ Add one to update it ‣ Write new value to the database ‣ Return original value to the user ‣ Read current value from the database ‣ Add one to update it ‣ Write new value to the database ‣ Return original value to the user WHAT’S THE FINAL VALUE? 1? 2?
  27. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE WE DON’T KNOW

  28. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE THE PAGES SERVED

    COUNTER ‣ Read current value from the database ‣ Add one to update it ‣ Write new value to the database ‣ Return new value to the user ‣ Read current value from the database ‣ Add one to update it ‣ Write new value to the database ‣ Return new value to the user
  29. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE ‣ Read current

    value from the database 0 ‣ Read current value from the database 0 ‣ Add one to update it 1 ‣ Add one to update it 1 ‣ Write new value to the database 1 ‣ Write new value to the database 1 ‣ Return new value to the user 1 ‣ Return new value to the user 1 Request A Request B
  30. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE ‣ Read current

    value from the database 0 ‣ Add one to update it 1 ‣ Write new value to the database 1 ‣ Return new value to the user 1 ‣ Read current value from the database 1 ‣ Add one to update it 2 ‣ Write new value to the database 2 ‣ Return new value to the user 2 Request A Request B
  31. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE ‣ Read current

    value from the database 0 ‣ Add one to update it 1 ‣ Write new value to the database 1 ‣ Read current value from the database 1 ‣ Return new value to the user 1 ‣ Add one to update it 2 ‣ Write new value to the database 2 ‣ Return new value to the user 2 Request A Request B
  32. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE ‣ Read current

    value from the database 0 ‣ Add one to update it 1 ‣ Write new value to the database 1 ‣ Read current value from the database 1 ‣ Return new value to the user 1 ‣ Add one to update it 2 ‣ Write new value to the database 2 ‣ Return new value to the user 2 Request A Request B
  33. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE ‣ Read current

    value from the database 0 ‣ Add one to update it 1 ‣ Write new value to the database 1 ‣ Read current value from the database 1 ‣ Return new value to the user 1 ‣ Add one to update it 2 ‣ Write new value to the database 2 ‣ Return new value to the user 2 Request A Request B
  34. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE WE’RE EXPERIENCING A

    DATA RACE
  35. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE RECIPE FOR A

    DATA RACE ▸ A shared value ▸ Concurrency ▸ At least one writer changing the shared value ▸ Non-atomic operations
  36. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE OUR DATABASE IS

    A SHARED VALUE
  37. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE CONCURRENCY: WE HAVE

    TWO REQUESTS
  38. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE WHOLE LOTTA WRITING

    GOING ON
  39. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE OUR INCREMENTING ISN’T

    ATOMIC
  40. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE AN OPERATION IS

    ATOMIC IF IT’S ISOLATED FROM OTHER OPERATIONS HAPPENING AT THE SAME TIME.
  41. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE ‣ Read current

    value from the database 0 ‣ Read current value from the database 0 ‣ Add one to update it 1 ‣ Add one to update it 1 ‣ Write new value to the database 1 ‣ Write new value to the database 1 ‣ Return new value to the user 1 ‣ Return new value to the user 1 Request A Request B
  42. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE ‣ Read current

    value from the database 0 ‣ Read current value from the database 0 ‣ Add one to update it 1 ‣ Add one to update it 1 ‣ Write new value to the database 1 ‣ Write new value to the database 1 ‣ Return new value to the user 1 ‣ Return new value to the user 1 Request A Request B
  43. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE ‣ Increment current

    value 1 ‣ Increment current value 2 ‣ Read new value 2 ‣ Read new value 2 ‣ Return new value to the user 2 ‣ Return new value to the user 2 Request A Request B
  44. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE ‣ Increment current

    value 1 ‣ Increment current value 2 ‣ Read new value 2 ‣ Read new value 2 ‣ Return new value to the user 2 ‣ Return new value to the user 2 Request A Request B
  45. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE MORE CONCURRENCY MORE

    PROBLEMS
  46. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE 0 0 1

    1 1 2 Request A Request B Request C
  47. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE 0 0 1

    1 1 2 Request A Request B Request C
  48. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE 0 0 1

    1 1 2 Request A Request B Request C
  49. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE 0 0 1

    1 1 2 Request A Request B Request C
  50. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE DATABASE VALUE IS

    1
  51. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE 0 0 1

    1 1 2 Request A Request B Request C
  52. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE 0 0 1

    1 1 2 Request A Request B Request C
  53. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE 0 0 1

    1 1 2 Request A Request B Request C
  54. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE DATABASE VALUE INCREASED

    TO 2
  55. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE 0 0 1

    1 1 2 Request A Request B Request C
  56. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE 0 0 1

    1 1 2 Request A Request B Request C
  57. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE DATABASE VALUE DECREASED

    TO 1
  58. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE WE’RE EXPERIENCING LAST

    WRITE WINS
  59. LAST WRITE WINS MEANS “SOME WRITES LOSE”. Sean Cribbs &

    Russell Brown DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE
  60. LAST WRITE WINS IS A FANCY NAME FOR “LET’S CORRUPT

    SOME DATA”. Sean T. Allen DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE
  61. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE OUR MOST POPULAR

    ARCHITECTURES FOR SCALING
  62. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE THESE PROBLEMS ARE

    EVERYWHERE
  63. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE “SERVERLESS”

  64. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE “FUNCTIONS AS SERVICE”

  65. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE “STATELESS”

  66. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE “SHARED NOTHING”

  67. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE ALL FEATURE DATABASE

    AS A SHARED VALUE AND CONCURRENT WRITES
  68. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE ALL HAVE DATA

    CORRUPTION BAKED INTO THE CORE ARCHITECTURE
  69. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE WHAT CAN WE

    DO?
  70. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE RECIPE FOR A

    DATA RACE: CHANGE AT LEAST ONE ▸ A shared value ▸ Concurrency ▸ At least one writer changing the shared value ▸ Non-atomic operations
  71. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE STORED PROCEDURES AND

    TRANSACTIONS
  72. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE DISTRIBUTED TRANSACTIONS

  73. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE SYNCHRONIZE DATA ACCESS

  74. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE CONSENSUS ALGORITHMS

  75. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE CONCURRENCY FRIENDLY DATA

    STRUCTURES
  76. DATA CORRUPTING ARCHITECTURES WE KNOW AND LOVE COMMUNICATE OPERATIONS NOT


    VALUES
  77. GITHUB.COM/ SEANTALLEN/DATA- CORRUPTING- ARCHITECTURES LEARN MORE