Distributed Systems
   and Consistency




Because everything else is easy.
What we're talking about
●   What are distributed systems?
●   Why are they good, why are they bad?
●   CAP theorem
●   Possible CAP configurations
●   Strategies for consistency, including:
    ●   Point-in-time consistency with LSS
    ●   Vector clocks for distributed consistency
    ●   CRDTs for consistency from the data structure
    ●   Bloom, a natively consistent distributed language
What's a distributed system?
●   Short answer: big data systems
    ●   Lots of machines, geographically distributed
●   Technical answer:
    ●   Any system where events are not global
    ●   Where events can happen simultaneously
Why are they good?
●   Centralized systems scale poorly & expensively
    ●   More locks, more contention
    ●   Expensive hardware
    ●   Vertical scaling
●   Distributed systems scale well & cheaply
    ●   No locks, no contention
    ●   (Lots of) cheap hardware
    ●   Linear scaling
So what's the catch?
●   Consistency
    ●   “Easy” in centralized systems
    ●   Hard in distributed systems
CAP Theorem
●   Consistency
    ●   All nodes see the same data at the same time
●   Availability
    ●   Every request definitely succeeds or fails
●   Partition tolerance
    ●   System operates despite message loss, failure
●   Pick two!
No P
●   No partition tolerance = centralized
    ●   Writes can't reach the store? Broken.
    ●   Reads can't find the data? Broken.
●   The most common database type
    ●   MySQL
    ●   Postgres
    ●   Oracle
No A
●   An unavailable database = a crappy database
    ●   Read or write didn't work? Try again.
    ●   Everything sacrifices A to some degree
●   Has some use-cases
    ●   High-volume logs & statistics
    ●   Google BigTable
    ●   Mars orbiters!
No C
●   Lower consistency = distributed systems
    ●   “Eventual consistency”
    ●   Writes will work, or definitely fail
    ●   Reads will work, but might not be entirely true
●   The new hotness
    ●   Amazon S3, Riak, Google Spanner
Why is this suddenly cool?
●   The economics of computing have changed
●   Networking was rare and expensive
    ●   Now cheap and ubiquitous – lots more P
●   Storage was expensive
    ●   Now ridiculously cheap – allows new approaches
●   Partition happens
    ●   Deliberately sacrifice Consistency
    ●   Instead of accidentally sacrificing Availability
Ways to get to eventual consistency
●   App level:
    ●   Write locking
    ●   Last write wins
●   Infrastructure level
    ●   Log structured storage
    ●   Multiversion concurrency control
    ●   Vector clocks and siblings
●   New: language level!
    ●   Bloom
Write-time consistency 1
●   Write-time locking
    ●   Distributed reads
    ●   (Semi)-centralized writes
    ●   Cheap, fast reads (but can be stale)
    ●   Slower writes, potential points of failure
●   In the wild:
    ●   Clipboard.com
    ●   Awe.sm!
Write-time consistency 2
●   Last write wins
    ●   Cheap reads
    ●   Cheap writes
    ●   Can silently lose data!
        –   A sacrifice of Availability
●   In the wild:
    ●   Amazon S3
Side note: Twitter
●   Twitter is eventually consistent!
●   Your timeline isn't guaranteed correct
●   Older tweets can appear or disappear
●   Twitter sacrifices C for A and P
    ●   But doesn't get a lot of A
Infrastructure level consistency 1
●   Log structured storage
    ●   Also called append-only databases
    ●   A new angle on consistency: external consistency
    ●   a.k.a. Point-in-time consistency
●   In the wild:
    ●   BigTable
    ●   Spanner
How LSS Works
●   Every write is appended
●   Indexes are built and appended
●   Reads work backwards through the log
●   Challenges
    ●   Index-building can get chunky
        –   Build them in memory, easily rebuilt
    ●   Garbage collection
        –   But storage is cheap now!
Why is LSS so cool?
●   Easier to manage big data
    ●   Size, schema, allocation of storage simplified
●   Indexes are impossible to corrupt
●   Reads and writes are cheap
●   Point-in-time consistency is free!
    ●   Called Multiversion Concurrency Control
Infrastructure level consistency 2
●   Vector clocks
    ●   Vectors as in math
    ●   Basically an array
Distributed systems and consistency
Distributed systems and consistency
Not enough for consistency
●   Different nodes know different things!
●   Quorum reads
    ●   N or more nodes must agree
●   Quorum writes
    ●   N or more nodes must receive new value
●   Can tune N for your application
But siblings suck!
Dealing with siblings
●   1: Consistency at read time
    ●   Slower reads
    ●   Pay every time
●   2: Consistency at write time
    ●   Slower writes
    ●   Pay once
●   3: Consistency at infrastructure level
    ●   CRDTs: Commutative Replicated Data Types
    ●   Monotonic lattices of commutative operations
Don't Panic
●   We're going to go slowly
●   There's no math
Monotonicity
●   Operations only affect the data in one way
    ●   e.g. increment vs. set
●   Instead of storing values, store operations
Commutativity
●   Means the order of operations isn't important
    ●   1 + 5 + 10 == 10 + 5 + 1
    ●   Also: (1+5) + 10 == (10+5) + 1
●   You don't need to know when stuff happened
●   Just what happened
Lattices
●   A data structure of operations
    ●   Like a vector clock, sets of operations
●   “Partially” ordered
    ●   Means you can throw away oldest operations
Put it all together: CRDTs
●   Commutative Replicated Data Types
    ●   Each node stores every entry as a lattice
    ●   Lattices are distributed and merged
    ●   Operations are commutative
        –   So collisions don't break stuff
CRDTs are monotonic
●   Each new operation adds information
●   Data is never deleted or destroyed
●   Applications don't need to know
●   Everything is in the store
CRDTs are pretty awesome
●   But
    ●   use a lot more space
    ●   garbage collection is non-trivial
●   In the wild:
    ●   The data processor!
Language level consistency
●   Bloom
    ●   A natively distributed-safe language
    ●   All operations are monotonic and commutative
    ●   Allows compiler-level analysis
    ●   Flag where unsafe things are happening
        –   And suggest fixes and coordination
    ●   Crazy future stuff
In Summary
●   Big data is easy
    ●   Just use distributed systems!
●   Consistency is hard
    ●   The solution may be in data structures
    ●   Making use of radically cheaper storage
●   Store operations, not values
    ●   And make operations commutative
●   Data is so cool!
More reading
●   Log Structured Storage:
    ●   http://blog.notdot.net/2009/12/Damn-Cool-Algorithms-Log-structured-
        storage
●   Lattice data structures and CALM theorem:
    ●   http://db.cs.berkeley.edu/papers/UCB-lattice-tr.pdf
●   Bloom:
    ●   http://www.bloom-lang.net/
●   Ops: Riak in the Cloud
    ●   https://speakerdeck.com/u/randommood/p/getting-starte
Even more reading
●   http://en.wikipedia.org/wiki/Multiversion_concurrency_control
●   http://en.wikipedia.org/wiki/Monotonic_function
●   http://en.wikipedia.org/wiki/Commutative_property
●   http://en.wikipedia.org/wiki/CAP_theorem
●   http://en.wikipedia.org/wiki/Fallacies_of_Distributed_Computing
●   http://pagesperso-systeme.lip6.fr/Marc.Shapiro/papers/RR-6956.pdf
●   http://en.wikipedia.org/wiki/Vector_clock

More Related Content

PDF
Consistency Models in New Generation Databases
PPT
CAP, PACELC, and Determinism
PDF
Database Consistency Models
PDF
Consistency in Distributed Systems, Part 2
PDF
An Overview of Distributed Debugging
PPTX
CAP Theorem - Theory, Implications and Practices
PDF
The Economics of Scale: Promises and Perils of Going Distributed
PPTX
CAP Theorem
Consistency Models in New Generation Databases
CAP, PACELC, and Determinism
Database Consistency Models
Consistency in Distributed Systems, Part 2
An Overview of Distributed Debugging
CAP Theorem - Theory, Implications and Practices
The Economics of Scale: Promises and Perils of Going Distributed
CAP Theorem

What's hot (20)

PDF
Simple Solutions for Complex Problems
PPTX
NoSQL Evolution
PDF
The CAP Theorem
PDF
BASE: An Acid Alternative
PDF
Distributed Systems: scalability and high availability
PPTX
NoSQL databases, the CAP theorem, and the theory of relativity
PDF
Architecting for the cloud elasticity security
PDF
Architecting for the cloud cloud providers
PDF
CAP theorem and distributed systems
PPT
Design principles of scalable, distributed systems
PPT
Client Centric Consistency Model
PPTX
Database , 13 Replication
PDF
Lightning talk: highly scalable databases and the PACELC theorem
PDF
Select Stars: A DBA's Guide to Azure Cosmos DB (Chicago Suburban SQL Server U...
PDF
DIY: A distributed database cluster, or: MySQL Cluster
PPTX
Hbase hivepig
PPTX
Natural Laws of Software Performance
PDF
Select Stars: A SQL DBA's Introduction to Azure Cosmos DB (SQL Saturday Orego...
DOCX
data replication
PPT
Consistency protocols
Simple Solutions for Complex Problems
NoSQL Evolution
The CAP Theorem
BASE: An Acid Alternative
Distributed Systems: scalability and high availability
NoSQL databases, the CAP theorem, and the theory of relativity
Architecting for the cloud elasticity security
Architecting for the cloud cloud providers
CAP theorem and distributed systems
Design principles of scalable, distributed systems
Client Centric Consistency Model
Database , 13 Replication
Lightning talk: highly scalable databases and the PACELC theorem
Select Stars: A DBA's Guide to Azure Cosmos DB (Chicago Suburban SQL Server U...
DIY: A distributed database cluster, or: MySQL Cluster
Hbase hivepig
Natural Laws of Software Performance
Select Stars: A SQL DBA's Introduction to Azure Cosmos DB (SQL Saturday Orego...
data replication
Consistency protocols
Ad

Viewers also liked (18)

PPT
process management
PPT
Chap 4
PPTX
Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency i...
PDF
Scaling Scribd
PPTX
Scaling up food safety information transparency
ODP
Consistency in Distributed Systems
PPTX
Distributed System Management
PPTX
The elements of scale
PPT
3. challenges
PPT
3. distributed file system requirements
PDF
Client-centric Consistency Models
ODP
Distributed shared memory shyam soni
PPT
message passing
PDF
Transparency - The Double-Edged Sword
PPT
distributed shared memory
PPT
Distributed & parallel system
PPT
Distributed Systems
DOC
Unit 1 architecture of distributed systems
process management
Chap 4
Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency i...
Scaling Scribd
Scaling up food safety information transparency
Consistency in Distributed Systems
Distributed System Management
The elements of scale
3. challenges
3. distributed file system requirements
Client-centric Consistency Models
Distributed shared memory shyam soni
message passing
Transparency - The Double-Edged Sword
distributed shared memory
Distributed & parallel system
Distributed Systems
Unit 1 architecture of distributed systems
Ad

Similar to Distributed systems and consistency (20)

PDF
AMW43 - Unba.se, Distributed database for human interaction
PDF
Scalable, good, cheap
PDF
Scalability broad strokes
PDF
Cassandra On EC2
PDF
Redis as a Main Database, Scaling and HA
PDF
Designing large scale distributed systems
PDF
kranonit S06E01 Игорь Цинько: High load
ODP
Cloud accounting software uk
PPTX
The Professional Programmer
PDF
Benchmarks, performance, scalability, and capacity what s behind the numbers...
PDF
Benchmarks, performance, scalability, and capacity what's behind the numbers
PDF
An Introduction to Apache Cassandra
PDF
Taskerman - a distributed cluster task manager
PDF
Olap scalability
PDF
Voxxed Athens 2018 - Methods and Practices for Guaranteed Failure in Big Data
PPTX
Productionizing Deep Learning From the Ground Up
PDF
Buytaert kris my_sql-pacemaker
PPTX
Introduction to AWS Big Data
PDF
MySQL 高可用性
PPTX
Productionizing dl from the ground up
AMW43 - Unba.se, Distributed database for human interaction
Scalable, good, cheap
Scalability broad strokes
Cassandra On EC2
Redis as a Main Database, Scaling and HA
Designing large scale distributed systems
kranonit S06E01 Игорь Цинько: High load
Cloud accounting software uk
The Professional Programmer
Benchmarks, performance, scalability, and capacity what s behind the numbers...
Benchmarks, performance, scalability, and capacity what's behind the numbers
An Introduction to Apache Cassandra
Taskerman - a distributed cluster task manager
Olap scalability
Voxxed Athens 2018 - Methods and Practices for Guaranteed Failure in Big Data
Productionizing Deep Learning From the Ground Up
Buytaert kris my_sql-pacemaker
Introduction to AWS Big Data
MySQL 高可用性
Productionizing dl from the ground up

Recently uploaded (20)

PDF
Ebook - The Future of AI A Comprehensive Guide.pdf
PPTX
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
PDF
Optimizing bioinformatics applications: a novel approach with human protein d...
PDF
Technical Debt in the AI Coding Era - By Antonio Bianco
PDF
Examining Bias in AI Generated News Content.pdf
PPTX
Report in SIP_Distance_Learning_Technology_Impact.pptx
PDF
ELLIE29.pdfWETWETAWTAWETAETAETERTRTERTER
PDF
CCUS-as-the-Missing-Link-to-Net-Zero_AksCurious.pdf
PDF
Gestión Unificada de los Riegos Externos
PPTX
AQUEEL MUSHTAQUE FAKIH COMPUTER CENTER .
PPTX
How to Convert Tickets Into Sales Opportunity in Odoo 18
PDF
ment.tech-Siri Delay Opens AI Startup Opportunity in 2025.pdf
PPT
Overviiew on Intellectual property right
PDF
Introduction to MCP and A2A Protocols: Enabling Agent Communication
PPTX
Information-Technology-in-Human-Society.pptx
PDF
Chapter 1: computer maintenance and troubleshooting
PDF
Addressing the challenges of harmonizing law and artificial intelligence tech...
PPTX
Blending method and technology for hydrogen.pptx
PPTX
Digital Convergence: How GIS, BIM, and CAD Revolutionize Asset Management
PPTX
Information-Technology-in-Human-Society (2).pptx
Ebook - The Future of AI A Comprehensive Guide.pdf
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
Optimizing bioinformatics applications: a novel approach with human protein d...
Technical Debt in the AI Coding Era - By Antonio Bianco
Examining Bias in AI Generated News Content.pdf
Report in SIP_Distance_Learning_Technology_Impact.pptx
ELLIE29.pdfWETWETAWTAWETAETAETERTRTERTER
CCUS-as-the-Missing-Link-to-Net-Zero_AksCurious.pdf
Gestión Unificada de los Riegos Externos
AQUEEL MUSHTAQUE FAKIH COMPUTER CENTER .
How to Convert Tickets Into Sales Opportunity in Odoo 18
ment.tech-Siri Delay Opens AI Startup Opportunity in 2025.pdf
Overviiew on Intellectual property right
Introduction to MCP and A2A Protocols: Enabling Agent Communication
Information-Technology-in-Human-Society.pptx
Chapter 1: computer maintenance and troubleshooting
Addressing the challenges of harmonizing law and artificial intelligence tech...
Blending method and technology for hydrogen.pptx
Digital Convergence: How GIS, BIM, and CAD Revolutionize Asset Management
Information-Technology-in-Human-Society (2).pptx

Distributed systems and consistency

  • 1. Distributed Systems and Consistency Because everything else is easy.
  • 2. What we're talking about ● What are distributed systems? ● Why are they good, why are they bad? ● CAP theorem ● Possible CAP configurations ● Strategies for consistency, including: ● Point-in-time consistency with LSS ● Vector clocks for distributed consistency ● CRDTs for consistency from the data structure ● Bloom, a natively consistent distributed language
  • 3. What's a distributed system? ● Short answer: big data systems ● Lots of machines, geographically distributed ● Technical answer: ● Any system where events are not global ● Where events can happen simultaneously
  • 4. Why are they good? ● Centralized systems scale poorly & expensively ● More locks, more contention ● Expensive hardware ● Vertical scaling ● Distributed systems scale well & cheaply ● No locks, no contention ● (Lots of) cheap hardware ● Linear scaling
  • 5. So what's the catch? ● Consistency ● “Easy” in centralized systems ● Hard in distributed systems
  • 6. CAP Theorem ● Consistency ● All nodes see the same data at the same time ● Availability ● Every request definitely succeeds or fails ● Partition tolerance ● System operates despite message loss, failure ● Pick two!
  • 7. No P ● No partition tolerance = centralized ● Writes can't reach the store? Broken. ● Reads can't find the data? Broken. ● The most common database type ● MySQL ● Postgres ● Oracle
  • 8. No A ● An unavailable database = a crappy database ● Read or write didn't work? Try again. ● Everything sacrifices A to some degree ● Has some use-cases ● High-volume logs & statistics ● Google BigTable ● Mars orbiters!
  • 9. No C ● Lower consistency = distributed systems ● “Eventual consistency” ● Writes will work, or definitely fail ● Reads will work, but might not be entirely true ● The new hotness ● Amazon S3, Riak, Google Spanner
  • 10. Why is this suddenly cool? ● The economics of computing have changed ● Networking was rare and expensive ● Now cheap and ubiquitous – lots more P ● Storage was expensive ● Now ridiculously cheap – allows new approaches ● Partition happens ● Deliberately sacrifice Consistency ● Instead of accidentally sacrificing Availability
  • 11. Ways to get to eventual consistency ● App level: ● Write locking ● Last write wins ● Infrastructure level ● Log structured storage ● Multiversion concurrency control ● Vector clocks and siblings ● New: language level! ● Bloom
  • 12. Write-time consistency 1 ● Write-time locking ● Distributed reads ● (Semi)-centralized writes ● Cheap, fast reads (but can be stale) ● Slower writes, potential points of failure ● In the wild: ● Clipboard.com ● Awe.sm!
  • 13. Write-time consistency 2 ● Last write wins ● Cheap reads ● Cheap writes ● Can silently lose data! – A sacrifice of Availability ● In the wild: ● Amazon S3
  • 14. Side note: Twitter ● Twitter is eventually consistent! ● Your timeline isn't guaranteed correct ● Older tweets can appear or disappear ● Twitter sacrifices C for A and P ● But doesn't get a lot of A
  • 15. Infrastructure level consistency 1 ● Log structured storage ● Also called append-only databases ● A new angle on consistency: external consistency ● a.k.a. Point-in-time consistency ● In the wild: ● BigTable ● Spanner
  • 16. How LSS Works ● Every write is appended ● Indexes are built and appended ● Reads work backwards through the log ● Challenges ● Index-building can get chunky – Build them in memory, easily rebuilt ● Garbage collection – But storage is cheap now!
  • 17. Why is LSS so cool? ● Easier to manage big data ● Size, schema, allocation of storage simplified ● Indexes are impossible to corrupt ● Reads and writes are cheap ● Point-in-time consistency is free! ● Called Multiversion Concurrency Control
  • 18. Infrastructure level consistency 2 ● Vector clocks ● Vectors as in math ● Basically an array
  • 21. Not enough for consistency ● Different nodes know different things! ● Quorum reads ● N or more nodes must agree ● Quorum writes ● N or more nodes must receive new value ● Can tune N for your application
  • 23. Dealing with siblings ● 1: Consistency at read time ● Slower reads ● Pay every time ● 2: Consistency at write time ● Slower writes ● Pay once ● 3: Consistency at infrastructure level ● CRDTs: Commutative Replicated Data Types ● Monotonic lattices of commutative operations
  • 24. Don't Panic ● We're going to go slowly ● There's no math
  • 25. Monotonicity ● Operations only affect the data in one way ● e.g. increment vs. set ● Instead of storing values, store operations
  • 26. Commutativity ● Means the order of operations isn't important ● 1 + 5 + 10 == 10 + 5 + 1 ● Also: (1+5) + 10 == (10+5) + 1 ● You don't need to know when stuff happened ● Just what happened
  • 27. Lattices ● A data structure of operations ● Like a vector clock, sets of operations ● “Partially” ordered ● Means you can throw away oldest operations
  • 28. Put it all together: CRDTs ● Commutative Replicated Data Types ● Each node stores every entry as a lattice ● Lattices are distributed and merged ● Operations are commutative – So collisions don't break stuff
  • 29. CRDTs are monotonic ● Each new operation adds information ● Data is never deleted or destroyed ● Applications don't need to know ● Everything is in the store
  • 30. CRDTs are pretty awesome ● But ● use a lot more space ● garbage collection is non-trivial ● In the wild: ● The data processor!
  • 31. Language level consistency ● Bloom ● A natively distributed-safe language ● All operations are monotonic and commutative ● Allows compiler-level analysis ● Flag where unsafe things are happening – And suggest fixes and coordination ● Crazy future stuff
  • 32. In Summary ● Big data is easy ● Just use distributed systems! ● Consistency is hard ● The solution may be in data structures ● Making use of radically cheaper storage ● Store operations, not values ● And make operations commutative ● Data is so cool!
  • 33. More reading ● Log Structured Storage: ● http://blog.notdot.net/2009/12/Damn-Cool-Algorithms-Log-structured- storage ● Lattice data structures and CALM theorem: ● http://db.cs.berkeley.edu/papers/UCB-lattice-tr.pdf ● Bloom: ● http://www.bloom-lang.net/ ● Ops: Riak in the Cloud ● https://speakerdeck.com/u/randommood/p/getting-starte
  • 34. Even more reading ● http://en.wikipedia.org/wiki/Multiversion_concurrency_control ● http://en.wikipedia.org/wiki/Monotonic_function ● http://en.wikipedia.org/wiki/Commutative_property ● http://en.wikipedia.org/wiki/CAP_theorem ● http://en.wikipedia.org/wiki/Fallacies_of_Distributed_Computing ● http://pagesperso-systeme.lip6.fr/Marc.Shapiro/papers/RR-6956.pdf ● http://en.wikipedia.org/wiki/Vector_clock

Editor's Notes

  • #4: - What's a distributed system? - Short answer: "big data" - Lots of machines, geographically distributed - Actual answer: any system where events are not global - Can a read and write happen at the same time? == Distributed - Mostly things are queued - Or in database systems, it's fudged -- no lock, so no problem
  • #5: - Why are they good? - Centralized systems scale poorly & expensively - More locks, more contention - Really fast hardware - Vertical scaling - Diminishing returns -- will always eventually fail - Distributed systems scale well & cheaply - Lots of cheap hardware - No locks, no contention - Linear scaling -- can theoretically scale indefinitely
  • #6: - So what's the catch? - Consistency - In a centralized system consistency is simple: single source of truth - The problem is writing to it performantly - In a distributed system writes are really fast - But the definition of "truth" is much, much harder
  • #7: - CAP theorem - Consistency (all nodes see the same data at the same time) - Availability (a guarantee that every request receives a response about whether it was successful or failed) - Partition tolerance (the system continues to operate despite arbitrary message loss or failure of part of the system) - Pick 2 - But actually it's usually a sliding scale
  • #8: - P: No partition tolerance = centralized database - Can't connect to read or write? You're broken. - Replication log got corrupted? You're broken. <img: welcome to our ool>
  • #9: - A: No availability guarantee = guessing - Read or write didn't work: try again - Cost/benefit calculation -- everything is unavailable *sometimes* - High-volume logs, statistics - Google BigTable locks data on write, will throw errors if you try to read it - Mars orbiters! Not all the data makes it back, and that's okay.
  • #10: - C: Lower consistency = Amazon S3, Riak, other distributed systems - "Eventual" consistency - Write will work, or definitely fail - Reads will work, but might not be "true" - Keep retrying for the truth
  • #11: - Why is this a big deal now? - The last 10 years have been about systems getting so big that P has become a bigger and bigger problem - Network was expensive, now it's cheap - And everything is networked - Storage was expensive, now it's cheap - Sacrificing A has been the accidental solution - Instead we can deliberately dial down C to get bigger
  • #12: - Ways to get to eventual consistency - There are a ton! - App level: - Write locking - Last write wins - Infrastructure level: - Log structured storage, multiversion concurrency control - Vector clocks and siblings - New: language level! - Bloom
  • #13: - Eventual consistency at write time: 1 - Write-time locking - Like a centralized database, except reads are okay with stale data - Slower writes, potential points of failure - Cheap, fast reads
  • #14: - Eventual consistency at write time: 2 - Last write wins - This is Amazon S3. - Relies on accurate clocks - Cheap reads and writes - Can lose data! - Okay for image files, bad for payment processing
  • #15: - Side note: twitter is eventually consistent - Your timeline doesn't always turn up exactly in order - Older tweets can slot themselves in - Tweets can disappear - Two new tweets can never collide - This is a form of eventual consistency, last write wins, but no conflicts
  • #16: - A consistency approach: log-structured storage - Also called append-only databases - Eventual consistency where *consistency* is important, but *currency* is not <diagram>
  • #17: - How LSS works - Each write is appended - Indexes are also appended - To get a value, consult the index - As the data grows, throw away older values - Index doesn't need to be updated as often - If you find operations before the index, rebuild an index from them - Relies of lots of really cheap storage - But it turns out we have that!
  • #18: - Why is this good? - Don't have to care about the size or schema of the object - Deleting old objects is automatic - Can't corrupt the index - Reads and writes are cheap - Point-in-time consistency is automatic: just read values older than the one you started with - BUT: you still could be behind reality
  • #19: - Another consistency approach: vector clocks - Eventual consistency where consistency and currency both matter - Vector, as in math - It means an array, but mathematicians are annoying <diagram> - Simultaneous writes produce siblings - never any data lost
  • #22: - Not good enough! - Read consistency: quorum reads - N or more sources must return the same value - Write consistency: quorum writes - N or more nodes must receive the new value
  • #23: - Pretty good - But man do siblings suck! http://3.bp.blogspot.com/-h60iS4_uwfg/T2B4rntiV4I/AAAAAAAAK9M/Wc_jaXLRowg/s400/istock_brothers-fighting-300x198.jpg
  • #24: - Dealing with siblings - 1: Consistency at read time through clever resolution - Cheap, fast writes - Potentially slower reads, duplicated dispute resolution logic - Pay on every read - 2: Avoid creating them in the first place - Put a sharded lock in front of your writes - Potentially slower writes - Pay once on write - 3: CRDTs: Commutative Replicated Data Types - monotonic lattices of commutative operations - Don't panic
  • #26: - Monotonicity - Means operations only affect the data in one way - Simplest example: setter vs. incrementer - Bad: http://en.wikipedia.org/wiki/File:Monotonicity_example3.png - Good: http://en.wikipedia.org/wiki/File:Monotonicity_example1.png - The setter can get it wrong, destroy information - The incrementer doesn't need to know the exact value, just that it goes up by one ( Also good: http://en.wikipedia.org/wiki/File:Monotonicity_example2.png ) - Instead of storing values, store operations
  • #27: - Commutativity - Means the order of operations isn't important - 1 + 5 + 10 == 10 + 5 + 1 - Also: (1+5) + 10 == 1 + (5+10) - Means you don't need to know what order the operations happened in - Just that they happened
  • #28: - Lattices - A data structure consisting of a set of operatios - Like vector clocks, a (partial) order of operations - Doesn't have to be exact - Just enough to able to avoid having to re-run every operation every time
  • #29: - Put it all together: CRDTs - Commutative Replicated Data Types - Each node stores operations in a lattice - As data is distributed, lattices are merged - Because operations are commutative, collisions are okay - Because the exact order is irrelevant
  • #30: - CRDTs are a monotonic data structure - Each new operation only adds information - It's never taken away or destroyed - This is really exciting! - It means we don't have to build application logic to handle it - Just get your data types right, and the database will sort it out - Enables radically distributed systems
  • #32: - Crazy future shit: Bloom - A language where all the operations available are monotonic, commutative - Calls to non-monotonic operations are special - Allows for compiler-level analysis of distributed code - Flag in advance whether or not you are safe, where you need coordination, and what type - Crazy shit
  • #33: - In summary: - Big data is easy - Distributed systems are the answer - Distribution makes consistency harder in exchange for better partition - The solution may be changing the way data is stored - Don't store a value, store a sequence of operations - Make the operations commutative, the structure monotonic - Pretty cool stuff
  • #34: Log Structured Storage: http://blog.notdot.net/2009/12/Damn-Cool-Algorithms-Log-structured-storage Lattice data structures and CALM theorem: http://db.cs.berkeley.edu/papers/UCB-lattice-tr.pdf Bloom: http://www.bloom-lang.net/ Ops: Riak in the Cloud https://speakerdeck.com/u/randommood/p/getting-starte
  • #35: Other sources: http://en.wikipedia.org/wiki/Multiversion_concurrency_control http://en.wikipedia.org/wiki/Monotonic_function http://en.wikipedia.org/wiki/Commutative_property http://en.wikipedia.org/wiki/CAP_theorem http://en.wikipedia.org/wiki/Fallacies_of_Distributed_Computing http://pagesperso-systeme.lip6.fr/Marc.Shapiro/papers/RR-6956.pdf http://en.wikipedia.org/wiki/Vector_clock