SlideShare une entreprise Scribd logo
1  sur  41
Télécharger pour lire hors ligne
Roger	
  Bodamer
roger@10gen.com
    @rogerb
Thoughts on Transaction
          and
  Consistency Models
The database world is changing
Document Datastores, Key Value, Graph databases
The database world is changing
         Transactional model
The database world is changing
            Full Acid
The database world is changing
CAP
It is impossible in the asynchronous network model to
implement a read/write data object that guarantees the
following properties:
• Availability
• Atomic consistency in all fair executions (including those
in which messages are lost).
CAP
  It is impossible in the asynchronous network model to
  implement a read/write data object that guarantees the
  following properties:
  • Availability
  • Atomic consistency in all fair executions (including those
  in which messages are lost).

Or: If the network is broken, your database won’t work

But we get to define “won’t work”
Consistency Models - CAP

• Choices are Available-P (AP) or Consistent-P (CP)
• Write Availability, not Read Availability, is the Main Question

• It’s not all about CAP
   Scale, Reduced latency:
       •Multi data center
       •Speed
       •Even load distribution
Examples of Eventually
          Consistent Systems

• Eventual Consistency:
   •“The storage system guarantees that if no new
   updates are made to the object, eventually all
   accesses will return the last updated value”

•Examples:
   • DNS
   • Async replication (RDBMS, MongoDB)
   • Memcached (TTL cache)
Eventual Consistency
Eventual Consistency




Read(x)	
  :	
  1,	
  2,	
  2,	
  4,	
  4,	
  4,	
  4	
  …
Could we get this?




Read(x)	
  :	
  1,	
  2,	
  1,	
  4,	
  2,	
  4,	
  4,	
  4	
  …
Monotonic read consistency
Prevent	
  seeing	
  writes	
  out	
  of	
  order

                                 • Appserver and slave on same
                                 box
                                 • Appserver only reads from Slave

                                 • Eventually consistent
                                 • Guaranteed to see reads in
                                 order

                                 • Failover ?
RYOW Consistency
                                                             • Read Your Own
                                                 Primary     Writes
Read	
  /	
  	
  Has	
  Written
                                   Replication               • Eventually consistent
                                                             for readers
                                                 Secondary   • Immediately
                                                             consistent for writers
   Read
Amazon Dynamo

•R: # of servers to read from
•W: # servers to get response from
•N: Replication factor
   • R+W>N has nice properties
Example
Example	
  1

R	
  +	
  W	
  <=	
  N

R	
  =	
  1
W	
  =	
  1
N	
  =	
  5

Possibly	
  Stale	
  data
Higher	
  availability
Example
Example	
  1                   Example	
  2

R	
  +	
  W	
  <=	
  N         R	
  +	
  W	
  >	
  N

R	
  =	
  1                    R	
  =	
  2	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  R	
  =	
  1
W	
  =	
  1                    W	
  =	
  1	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  W	
  =	
  2
N	
  =	
  5                    N	
  =	
  2	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  N	
  =	
  2

Possibly	
  Stale	
  data      Consistent	
  data
Higher	
  availability
R+W>N
    If R+W > N, we can’t
       have both fast local
       reads and writes at
       the same time if all
       the data centers are
       equal peers
Consistency levels
• Strong: W + R > N
• Weak / Eventual : W + R <= N
• Optimized Read: R=1, W=N
• Optimized Write: W=1, R=N
Multi Datacenter Strategies
• DR
   • Failover
• Single Region, Multi Datacenter
   • Useful for Strong or Eventual Consistency
• Local Reads, Remote Writes
   • All writes to master on WAN, EC on Slaves
• Intelligent Homing
   • Master copy close to user location
Network Partitions
Network Write Possibilities
•Deny all writes
   • Still Read fully consistent data
   • Give up write Availability
Network Write Possibilities
•Deny all writes
   • Still Read fully consistent data
   • Give up write Availability

•Allow writes on one side
   • Failover
   • Possible to allow reads on other side
Network Write Possibilities
•Deny all writes
   • Still Read fully consistent data
   • Give up write Availability

•Allow writes on one side
   • Failover
   • Possible to allow reads on other side

•Allow writes on both sides
   • Available
   • Give up consistency
Multiple Writer Strategies
• Last one wins
   • Use Vector clocks to decide latest

• Insert
     Inserts often really means
       if ( !exists(x)) then set(x)
    exists is hard to implement in eventually
    consistent systems
Multiple Writer Strategies
• Delete
    op1: set( { _id : 'joe', age : 40 } }
    op2: delete( { _id : 'joe' } )
    op3: set( { _id : 'joe', age : 33 } )
• Consider switching 2 and 3
• Tombstone: Remember delete, and apply last-operation-wins

• Update
 update users set age=40 where _id=’joe’
However:
 op1: update users set age=40 where _id='joe'
 op2: update users set state='ca' where _id='joe'
Multiple Writer Strategies
• Programatic Merge
   • Store operations, instead of state
   • Replay operations
   • Did you get the last operation ?
   • Not immediate

•Communtative operations
   • Conflict free?
   • Fold-able
   • Example: add, increment, decrement
Trivial Network Partitions
MongoDB Options
MongoDB Transaction Support
• Single Master / Sharded

• MongoDB Supports Atomic Operations on Single Documents
   • But not Rollback
• $ operators
   • $set, $unset, $inc, $push, $pushall, $pull, $pullall
• Update if current
   • find followed by update
• Find and modify
MongoDB


                               Primary
Read	
  /	
  Write
MongoDB


                                       Primary
Read	
  /	
  Write
                         Replication


                                       Secondary


                         Replication


                                       Secondary	
  for	
  Backup
MongoDB


                                       Primary
Read	
  /	
  Write
                         Replication


                                       Secondary


     Read                Replication


                                       Secondary	
  for	
  Backup
MongoDB
                         Replicaset

                                       Primary
Read	
  /	
  Write
                         Replication


                                       Secondary


     Read                Replication


                                       Secondary	
  for	
  Backup
Write Scalability: Sharding
read      key	
  range	
      key	
  range	
      key	
  range	
  
            0	
  ..	
  30      31	
  ..	
  60      61	
  ..	
  100

         ReplicaSet	
  1     ReplicaSet	
  2     ReplicaSet	
  3



          Primary              Primary            Primary


         Secondary           Secondary           Secondary


         Secondary           Secondary           Secondary



                                                                     write
Sometimes we need global state /
      more consistency
•Unique key constraints
   •User registration
•ACL changes
Could it be the case that…


uptime( CP + average developer )
 >=
uptime( AP + average developer )

where uptime:= system is up and non-buggy?
Thank You :-)
  @rogerb
download at mongodb.org

                conferences,	
  appearances,	
  and	
  meetups
                                         http://www.10gen.com/events




    Facebook	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  |	
  	
  	
  	
  	
  	
  	
  	
  	
  Twitter	
  	
  	
  	
  	
  	
  	
  	
  	
  |	
  	
  	
  	
  	
  	
  	
  	
  	
  LinkedIn
http://bit.ly/mongoU	
                                                        @mongodb                                          http://linkd.in/joinmongo

Contenu connexe

Tendances

CAP, PACELC, and Determinism
CAP, PACELC, and DeterminismCAP, PACELC, and Determinism
CAP, PACELC, and Determinism
Daniel Abadi
 
Scala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache sparkScala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache spark
Demi Ben-Ari
 

Tendances (18)

CAP, PACELC, and Determinism
CAP, PACELC, and DeterminismCAP, PACELC, and Determinism
CAP, PACELC, and Determinism
 
Database Consistency Models
Database Consistency ModelsDatabase Consistency Models
Database Consistency Models
 
Functional? Reactive? Why?
Functional? Reactive? Why?Functional? Reactive? Why?
Functional? Reactive? Why?
 
NoSQL databases, the CAP theorem, and the theory of relativity
NoSQL databases, the CAP theorem, and the theory of relativityNoSQL databases, the CAP theorem, and the theory of relativity
NoSQL databases, the CAP theorem, and the theory of relativity
 
Kafka At Scale in the Cloud
Kafka At Scale in the CloudKafka At Scale in the Cloud
Kafka At Scale in the Cloud
 
Voldemort Nosql
Voldemort NosqlVoldemort Nosql
Voldemort Nosql
 
Stream or segment : what is the best way to access your events in Pulsar_Neng
Stream or segment : what is the best way to access your events in Pulsar_NengStream or segment : what is the best way to access your events in Pulsar_Neng
Stream or segment : what is the best way to access your events in Pulsar_Neng
 
Slashn Talk OLTP in Supply Chain - Handling Super-scale and Change Propagatio...
Slashn Talk OLTP in Supply Chain - Handling Super-scale and Change Propagatio...Slashn Talk OLTP in Supply Chain - Handling Super-scale and Change Propagatio...
Slashn Talk OLTP in Supply Chain - Handling Super-scale and Change Propagatio...
 
Data on its way to history, interrupted by analytics and silicon (@pavlobaron)
Data on its way to history, interrupted by analytics and silicon (@pavlobaron)Data on its way to history, interrupted by analytics and silicon (@pavlobaron)
Data on its way to history, interrupted by analytics and silicon (@pavlobaron)
 
Scala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache sparkScala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache spark
 
Low latency stream processing with jet
Low latency stream processing with jetLow latency stream processing with jet
Low latency stream processing with jet
 
Thinking Functionally with Clojure
Thinking Functionally with ClojureThinking Functionally with Clojure
Thinking Functionally with Clojure
 
Distributed query deep dive conor cunningham
Distributed query deep dive   conor cunninghamDistributed query deep dive   conor cunningham
Distributed query deep dive conor cunningham
 
Pnuts yahoo!’s hosted data serving platform
Pnuts  yahoo!’s hosted data serving platformPnuts  yahoo!’s hosted data serving platform
Pnuts yahoo!’s hosted data serving platform
 
Strata+Hadoop 2017 San Jose: Lessons from a year of supporting Apache Kafka
Strata+Hadoop 2017 San Jose: Lessons from a year of supporting Apache KafkaStrata+Hadoop 2017 San Jose: Lessons from a year of supporting Apache Kafka
Strata+Hadoop 2017 San Jose: Lessons from a year of supporting Apache Kafka
 
NewSQL overview, Feb 2015
NewSQL overview, Feb 2015NewSQL overview, Feb 2015
NewSQL overview, Feb 2015
 
Geographically Distributed PostgreSQL
Geographically Distributed PostgreSQLGeographically Distributed PostgreSQL
Geographically Distributed PostgreSQL
 
Spark Streaming & Kafka-The Future of Stream Processing
Spark Streaming & Kafka-The Future of Stream ProcessingSpark Streaming & Kafka-The Future of Stream Processing
Spark Streaming & Kafka-The Future of Stream Processing
 

En vedette

process management
 process management process management
process management
Ashish Kumar
 
Consistency in Distributed Systems
Consistency in Distributed SystemsConsistency in Distributed Systems
Consistency in Distributed Systems
Shane Johnson
 
Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency i...
Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency i...Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency i...
Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency i...
Legacy Typesafe (now Lightbend)
 
3. distributed file system requirements
3. distributed file system requirements3. distributed file system requirements
3. distributed file system requirements
AbDul ThaYyal
 
distributed shared memory
 distributed shared memory distributed shared memory
distributed shared memory
Ashish Kumar
 
Distributed & parallel system
Distributed & parallel systemDistributed & parallel system
Distributed & parallel system
Manish Singh
 
Distributed Systems
Distributed SystemsDistributed Systems
Distributed Systems
Rupsee
 
Unit 1 architecture of distributed systems
Unit 1 architecture of distributed systemsUnit 1 architecture of distributed systems
Unit 1 architecture of distributed systems
karan2190
 

En vedette (18)

Scaling up food safety information transparency
Scaling up food safety information transparencyScaling up food safety information transparency
Scaling up food safety information transparency
 
Distributed System Management
Distributed System ManagementDistributed System Management
Distributed System Management
 
process management
 process management process management
process management
 
Consistency in Distributed Systems
Consistency in Distributed SystemsConsistency in Distributed Systems
Consistency in Distributed Systems
 
The elements of scale
The elements of scaleThe elements of scale
The elements of scale
 
Scaling Scribd
Scaling ScribdScaling Scribd
Scaling Scribd
 
Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency i...
Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency i...Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency i...
Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency i...
 
Chap 4
Chap 4Chap 4
Chap 4
 
3. challenges
3. challenges3. challenges
3. challenges
 
3. distributed file system requirements
3. distributed file system requirements3. distributed file system requirements
3. distributed file system requirements
 
Client-centric Consistency Models
Client-centric Consistency ModelsClient-centric Consistency Models
Client-centric Consistency Models
 
message passing
 message passing message passing
message passing
 
Distributed shared memory shyam soni
Distributed shared memory shyam soniDistributed shared memory shyam soni
Distributed shared memory shyam soni
 
Transparency - The Double-Edged Sword
Transparency - The Double-Edged SwordTransparency - The Double-Edged Sword
Transparency - The Double-Edged Sword
 
distributed shared memory
 distributed shared memory distributed shared memory
distributed shared memory
 
Distributed & parallel system
Distributed & parallel systemDistributed & parallel system
Distributed & parallel system
 
Distributed Systems
Distributed SystemsDistributed Systems
Distributed Systems
 
Unit 1 architecture of distributed systems
Unit 1 architecture of distributed systemsUnit 1 architecture of distributed systems
Unit 1 architecture of distributed systems
 

Similaire à Consistency Models in New Generation Databases

What every developer should know about database scalability, PyCon 2010
What every developer should know about database scalability, PyCon 2010What every developer should know about database scalability, PyCon 2010
What every developer should know about database scalability, PyCon 2010
jbellis
 
Replication Solutions for PostgreSQL
Replication Solutions for PostgreSQLReplication Solutions for PostgreSQL
Replication Solutions for PostgreSQL
Peter Eisentraut
 
MongoDB Use Cases: Healthcare, CMS, Analytics
MongoDB Use Cases: Healthcare, CMS, AnalyticsMongoDB Use Cases: Healthcare, CMS, Analytics
MongoDB Use Cases: Healthcare, CMS, Analytics
MongoDB
 
SQL 2012 AlwaysOn Availability Groups (AOAGs) for SharePoint Farms - Norcall ...
SQL 2012 AlwaysOn Availability Groups (AOAGs) for SharePoint Farms - Norcall ...SQL 2012 AlwaysOn Availability Groups (AOAGs) for SharePoint Farms - Norcall ...
SQL 2012 AlwaysOn Availability Groups (AOAGs) for SharePoint Farms - Norcall ...
Michael Noel
 

Similaire à Consistency Models in New Generation Databases (20)

Thoughts on Transaction and Consistency Models
Thoughts on Transaction and Consistency ModelsThoughts on Transaction and Consistency Models
Thoughts on Transaction and Consistency Models
 
Thoughts on consistency models
Thoughts on consistency modelsThoughts on consistency models
Thoughts on consistency models
 
What every developer should know about database scalability, PyCon 2010
What every developer should know about database scalability, PyCon 2010What every developer should know about database scalability, PyCon 2010
What every developer should know about database scalability, PyCon 2010
 
Drop the Pressure on your Production Server
Drop the Pressure on your Production ServerDrop the Pressure on your Production Server
Drop the Pressure on your Production Server
 
Replication, Durability, and Disaster Recovery
Replication, Durability, and Disaster RecoveryReplication, Durability, and Disaster Recovery
Replication, Durability, and Disaster Recovery
 
MongoDB Replication fundamentals - Desert Code Camp - October 2014
MongoDB Replication fundamentals - Desert Code Camp - October 2014MongoDB Replication fundamentals - Desert Code Camp - October 2014
MongoDB Replication fundamentals - Desert Code Camp - October 2014
 
MongoDB World 2018: Active-Active Application Architectures: Become a MongoDB...
MongoDB World 2018: Active-Active Application Architectures: Become a MongoDB...MongoDB World 2018: Active-Active Application Architectures: Become a MongoDB...
MongoDB World 2018: Active-Active Application Architectures: Become a MongoDB...
 
MongoDB Replication fundamentals - Desert Code Camp - October 2014
MongoDB Replication fundamentals - Desert Code Camp - October 2014MongoDB Replication fundamentals - Desert Code Camp - October 2014
MongoDB Replication fundamentals - Desert Code Camp - October 2014
 
Power of the Log: LSM & Append Only Data Structures
Power of the Log: LSM & Append Only Data StructuresPower of the Log: LSM & Append Only Data Structures
Power of the Log: LSM & Append Only Data Structures
 
The Power of the Log
The Power of the LogThe Power of the Log
The Power of the Log
 
Replication Solutions for PostgreSQL
Replication Solutions for PostgreSQLReplication Solutions for PostgreSQL
Replication Solutions for PostgreSQL
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability Patterns
 
Mongosv 2011 - Replication
Mongosv 2011 - ReplicationMongosv 2011 - Replication
Mongosv 2011 - Replication
 
Application Profiling for Memory and Performance
Application Profiling for Memory and PerformanceApplication Profiling for Memory and Performance
Application Profiling for Memory and Performance
 
Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)
 
MongoDB Use Cases: Healthcare, CMS, Analytics
MongoDB Use Cases: Healthcare, CMS, AnalyticsMongoDB Use Cases: Healthcare, CMS, Analytics
MongoDB Use Cases: Healthcare, CMS, Analytics
 
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
 
Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014
 
SQL 2012 AlwaysOn Availability Groups (AOAGs) for SharePoint Farms - Norcall ...
SQL 2012 AlwaysOn Availability Groups (AOAGs) for SharePoint Farms - Norcall ...SQL 2012 AlwaysOn Availability Groups (AOAGs) for SharePoint Farms - Norcall ...
SQL 2012 AlwaysOn Availability Groups (AOAGs) for SharePoint Farms - Norcall ...
 
Select Stars: A DBA's Guide to Azure Cosmos DB (Chicago Suburban SQL Server U...
Select Stars: A DBA's Guide to Azure Cosmos DB (Chicago Suburban SQL Server U...Select Stars: A DBA's Guide to Azure Cosmos DB (Chicago Suburban SQL Server U...
Select Stars: A DBA's Guide to Azure Cosmos DB (Chicago Suburban SQL Server U...
 

Plus de iammutex

Realtime hadoopsigmod2011
Realtime hadoopsigmod2011Realtime hadoopsigmod2011
Realtime hadoopsigmod2011
iammutex
 

Plus de iammutex (20)

Scaling Instagram
Scaling InstagramScaling Instagram
Scaling Instagram
 
Redis深入浅出
Redis深入浅出Redis深入浅出
Redis深入浅出
 
深入了解Redis
深入了解Redis深入了解Redis
深入了解Redis
 
NoSQL误用和常见陷阱分析
NoSQL误用和常见陷阱分析NoSQL误用和常见陷阱分析
NoSQL误用和常见陷阱分析
 
MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用
 
8 minute MongoDB tutorial slide
8 minute MongoDB tutorial slide8 minute MongoDB tutorial slide
8 minute MongoDB tutorial slide
 
skip list
skip listskip list
skip list
 
Rethink db&tokudb调研测试报告
Rethink db&tokudb调研测试报告Rethink db&tokudb调研测试报告
Rethink db&tokudb调研测试报告
 
redis 适用场景与实现
redis 适用场景与实现redis 适用场景与实现
redis 适用场景与实现
 
Introduction to couchdb
Introduction to couchdbIntroduction to couchdb
Introduction to couchdb
 
What every data programmer needs to know about disks
What every data programmer needs to know about disksWhat every data programmer needs to know about disks
What every data programmer needs to know about disks
 
Ooredis
OoredisOoredis
Ooredis
 
Ooredis
OoredisOoredis
Ooredis
 
redis运维之道
redis运维之道redis运维之道
redis运维之道
 
Realtime hadoopsigmod2011
Realtime hadoopsigmod2011Realtime hadoopsigmod2011
Realtime hadoopsigmod2011
 
[译]No sql生态系统
[译]No sql生态系统[译]No sql生态系统
[译]No sql生态系统
 
Couchdb + Membase = Couchbase
Couchdb + Membase = CouchbaseCouchdb + Membase = Couchbase
Couchdb + Membase = Couchbase
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
 
Hadoop introduction berlin buzzwords 2011
Hadoop introduction   berlin buzzwords 2011Hadoop introduction   berlin buzzwords 2011
Hadoop introduction berlin buzzwords 2011
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

Consistency Models in New Generation Databases

  • 2. Thoughts on Transaction and Consistency Models
  • 3. The database world is changing Document Datastores, Key Value, Graph databases
  • 4. The database world is changing Transactional model
  • 5. The database world is changing Full Acid
  • 6. The database world is changing
  • 7. CAP It is impossible in the asynchronous network model to implement a read/write data object that guarantees the following properties: • Availability • Atomic consistency in all fair executions (including those in which messages are lost).
  • 8. CAP It is impossible in the asynchronous network model to implement a read/write data object that guarantees the following properties: • Availability • Atomic consistency in all fair executions (including those in which messages are lost). Or: If the network is broken, your database won’t work But we get to define “won’t work”
  • 9. Consistency Models - CAP • Choices are Available-P (AP) or Consistent-P (CP) • Write Availability, not Read Availability, is the Main Question • It’s not all about CAP Scale, Reduced latency: •Multi data center •Speed •Even load distribution
  • 10. Examples of Eventually Consistent Systems • Eventual Consistency: •“The storage system guarantees that if no new updates are made to the object, eventually all accesses will return the last updated value” •Examples: • DNS • Async replication (RDBMS, MongoDB) • Memcached (TTL cache)
  • 12. Eventual Consistency Read(x)  :  1,  2,  2,  4,  4,  4,  4  …
  • 13. Could we get this? Read(x)  :  1,  2,  1,  4,  2,  4,  4,  4  …
  • 14. Monotonic read consistency Prevent  seeing  writes  out  of  order • Appserver and slave on same box • Appserver only reads from Slave • Eventually consistent • Guaranteed to see reads in order • Failover ?
  • 15. RYOW Consistency • Read Your Own Primary Writes Read  /    Has  Written Replication • Eventually consistent for readers Secondary • Immediately consistent for writers Read
  • 16. Amazon Dynamo •R: # of servers to read from •W: # servers to get response from •N: Replication factor • R+W>N has nice properties
  • 17. Example Example  1 R  +  W  <=  N R  =  1 W  =  1 N  =  5 Possibly  Stale  data Higher  availability
  • 18. Example Example  1 Example  2 R  +  W  <=  N R  +  W  >  N R  =  1 R  =  2                                          R  =  1 W  =  1 W  =  1                                        W  =  2 N  =  5 N  =  2                                        N  =  2 Possibly  Stale  data Consistent  data Higher  availability
  • 19. R+W>N If R+W > N, we can’t have both fast local reads and writes at the same time if all the data centers are equal peers
  • 20. Consistency levels • Strong: W + R > N • Weak / Eventual : W + R <= N • Optimized Read: R=1, W=N • Optimized Write: W=1, R=N
  • 21. Multi Datacenter Strategies • DR • Failover • Single Region, Multi Datacenter • Useful for Strong or Eventual Consistency • Local Reads, Remote Writes • All writes to master on WAN, EC on Slaves • Intelligent Homing • Master copy close to user location
  • 23. Network Write Possibilities •Deny all writes • Still Read fully consistent data • Give up write Availability
  • 24. Network Write Possibilities •Deny all writes • Still Read fully consistent data • Give up write Availability •Allow writes on one side • Failover • Possible to allow reads on other side
  • 25. Network Write Possibilities •Deny all writes • Still Read fully consistent data • Give up write Availability •Allow writes on one side • Failover • Possible to allow reads on other side •Allow writes on both sides • Available • Give up consistency
  • 26. Multiple Writer Strategies • Last one wins • Use Vector clocks to decide latest • Insert Inserts often really means if ( !exists(x)) then set(x) exists is hard to implement in eventually consistent systems
  • 27. Multiple Writer Strategies • Delete op1: set( { _id : 'joe', age : 40 } } op2: delete( { _id : 'joe' } ) op3: set( { _id : 'joe', age : 33 } ) • Consider switching 2 and 3 • Tombstone: Remember delete, and apply last-operation-wins • Update update users set age=40 where _id=’joe’ However: op1: update users set age=40 where _id='joe' op2: update users set state='ca' where _id='joe'
  • 28. Multiple Writer Strategies • Programatic Merge • Store operations, instead of state • Replay operations • Did you get the last operation ? • Not immediate •Communtative operations • Conflict free? • Fold-able • Example: add, increment, decrement
  • 31. MongoDB Transaction Support • Single Master / Sharded • MongoDB Supports Atomic Operations on Single Documents • But not Rollback • $ operators • $set, $unset, $inc, $push, $pushall, $pull, $pullall • Update if current • find followed by update • Find and modify
  • 32. MongoDB Primary Read  /  Write
  • 33. MongoDB Primary Read  /  Write Replication Secondary Replication Secondary  for  Backup
  • 34. MongoDB Primary Read  /  Write Replication Secondary Read Replication Secondary  for  Backup
  • 35. MongoDB Replicaset Primary Read  /  Write Replication Secondary Read Replication Secondary  for  Backup
  • 36. Write Scalability: Sharding read key  range   key  range   key  range   0  ..  30 31  ..  60 61  ..  100 ReplicaSet  1 ReplicaSet  2 ReplicaSet  3 Primary Primary Primary Secondary Secondary Secondary Secondary Secondary Secondary write
  • 37.
  • 38. Sometimes we need global state / more consistency •Unique key constraints •User registration •ACL changes
  • 39. Could it be the case that… uptime( CP + average developer ) >= uptime( AP + average developer ) where uptime:= system is up and non-buggy?
  • 40. Thank You :-) @rogerb
  • 41. download at mongodb.org conferences,  appearances,  and  meetups http://www.10gen.com/events Facebook                    |                  Twitter                  |                  LinkedIn http://bit.ly/mongoU   @mongodb http://linkd.in/joinmongo