SlideShare a Scribd company logo
All you didn’t know about the CAP theorem
CAP theorem
The theorem was presented on the Symposium on Principles of
Distributed Computing in 2000 by Eric Brewer.
In 2002, Seth Gilbert and Nancy Lynch of MIT published a
formal proof of Brewer's conjecture, rendering it a theorem.
According to Brewer, he wanted the
community to start conversation about it,
but his words have been corrected and
treated as a theorem.
What stands behind the cap?
The CAP theorem states that in the distributed system you can
choose only 2 out of 3:
Consistency: every read would get you the most recent write
Availability: every node (if not failed) always executes
queries (read and writes)
Partition-tolerance: even if the connections between nodes
are down, the other two (A & C) promises, are kept.
AP Proof
Not consistent!
CP Proof
Not available!
CA Proof
No partition tolerance!
the CAP-triangle
Let’s take a look at the postgresql
Master/slave architecture is one of common solutions
Slave can be synced with master in async/sync way
The transaction system use two-phase commit to ensure consistency
If a partition occurs you can’t talk to the server (in the basic case), the
system is not CAP-available.
So, it can’t continue work in case of network partitioning, but it provides
strong consistency and high-availability. It’s a CA system!
Let’s take a look at the mongodb
MongoDB provides strong consistency, because it is a single-master system and
all writes go to the primary by default
MongoDB provides automatic failover in case of partitioning
If a partition occurs it will stop accepting writes to the system until it
believes that it can safely complete those writes.
So, it can continue work in case of network partitioning and it gives up
availability. It’s a CP system!
Let’s take a look at the
postgres + salesforce + heroku connect system
It’s master-master system
Heroku connect is responsible for keeping system consistency
Salesforce data and our postgres db doesn’t know about each other
If network partition occurs both storages will be available. Heroku connect
will try to reconnect.
So, it can continue work in case of network partitioning and it gives up
consistency. It should be an AP system!
It is so easy! Now I know everything!
Actually, no.
There are a lot of problems with CAP theorem:
CAP uses very narrow and far-from-the-real-world definitions
Actually, it is the choice only between consistency and availability
Many systems are neither CAP-consistent nor CAP-available
Pure AP systems are useless
Pure CP systems might behave not as expected
What is wrong with definitions
Consistency in CAP actually means linearizability (and it’s
really hard to reach it).
Availability in CAP is defined as “every request received by
a non-failing [database] node in the system must result in
a [non-error] response” and it’s not restricted by time.
The only fault considered by the CAP theorem is a network
partition.
Linearizability
Why node failures are outside CAP?
By the definition of availability: ...every node (if not
failed) always...
By the proof of CAP: the proof of CAP used by Gilbert and
Lynch relies on having code running on both sides of the
partition.
In some cases, a partition will be equivalent to a failure,
but this equivalence will be obtained by implementing a
specific logic in all the nodes.
Of course, we should manage node failures, but CAP doesn’t
help us here.
AP / CP choice
Partition Tolerance basically means that you’re communicating
over an asynchronous network that may delay or drop messages.
The internet and all our data centers have this property, so
you don’t really have any choice in this matter.
Many systems are only “p”
In case you have one master and
one slave, and you are
partitioned from the master - you
can’t write, but you can read.
It’s not CAP-available.
Ok, it’s a CP system, but usually
sync between slave and master is
async and there might be a gap
between sync and system
partitioning, so you do not have
CAP-consistency.
AP and CP problems
Pure AP is useless, it may just return any random value and
it would be an AP system
Pure CP is useless too, because partitioning in CAP have no
fixed duration, so the system provides only eventual
consistency, which is not the strong one that we want to
have.
Try to digest it
How to describe distributed system
Remember about CAP narrow definitions, as they
are still widely used
Use PACELC(A) theorem instead of CAP, it
provides additional consistency/latency
tradeoff
Describe how ACID/BASE principles apply to
your system
Decide if the system suits your needs,
considering the project you are working on.
Let’s take a look on PACELC(A)
The PACELC theorem was first described and formalised by Daniel J. Abadi from
Yale University in 2012.
IF there is a partition (P), how does the system tradeoff availability and
consistency (A and C)
ELSE (E) When the system is running normally in the absence of partitions, how
does the system trade off latency (L) and consistency (C)?
As PACELC theorem is based on CAP, it also uses CAP definitions.
PACELC(A) described systems
Let’s take a look on ACID
ACID - is a set of properties of database transactions.
Jim Gray defined these properties of a reliable transaction system in the late
1970s and developed technologies to achieve them automatically.
Database vendors long time ago introduced 2 phase commit for providing ACID
across multiple database instances.
Let’s take a look on ACID
Atomicity. All of the operations in the transaction will complete, or none
will
Consistency. The database will be in a consistent state when the transaction
begins and ends
Isolation. The transaction will behave as if it is the only operation being
performed upon the database
Durability. Once a transaction has been committed, it will remain so, even in
the event of power loss, crashes, or errors.
CAP/ACID definition confusion
Consistency in ACID relates to data integrity,
whereas Consistency in CAP is a reference for
Atomic Consistency (Linearizability), which
is a consistency model
Isolation term is not used in CAP, but it’s
definition in ACID is actually the same for
what linearizability stands for
Availability in ACID is not used in definitions,
but when it’s presented in articles, it means
the same as CAP-availability, apart that it’s
not required for all non-failing nodes to
respond.
Let’s take a look on BASE
Eventually consistent services are often classified
as providing BASE semantics, in contrast to
traditional ACID guarantees.
One of the earliest definitions of eventual
consistency comes from a 1988.
BASE essentially embraces the fact that true
consistency cannot be achieved in the real world,
and as such cannot be modelled in highly scalable
distributed systems.
What is BASE
Basic Availability states that there will be a response to any request, but,
that response could still be a “failure” or the data may be in an
inconsistent or changing state
Soft-state state of the system could change over time due to “eventual
consistency” changes
Eventual consistency states that the system will eventually become consistent,
the system will continue to receive input and is not checking the
consistency of every transaction before it moves onto the next one
Try to digest it too...
Fresh look on the postgres
Postgres does allow multiple cluster configuration, so it’s really hard to
describe all of them. Let’s just take the master - slave replication with the
Slony implementation.
The system works according ACID (there are couple of problems with two-phase
commit, but mostly it’s reliable)
In case of partition the Slony will try to proceed switchover and if all went
fine, we have our new master with its consistency
When there is no partition the Slony gives up latency and does everything to
approach strong consistency. Actually, ACID is the reason off high latency
The system is considered as PC/EC(A)
Fresh look on the mongodb
MongoDB is a NOSQL database.
MongoDB is ACID in limited sense at the document level
In case of distributed system - it’s all about BASE
In case of no partition, the system guarantees reads and writes to be
consistent
If the master node will be failed or partitioned from the rest of the system,
some data will not be replicated. System elects a new master to remain
available for reads and writes.(New master and old master are inconsistent)
The system is considered as PA/EC(A), as most of the nodes remain CAP-available
in case of partition.
fresh look on the
postgres + salesforce + heroku connect system
The Salesforce is an abstraction to oracle database (RDBMS) and the Postgres is
an actual RDBMS. Heroku connect is a tool to sync those too dbs. Let’s see what
we have…
Heroku connect, Postgres and Salesforce provide us ACID, but we can’t operate
with related entities
Surprise! The full system looks more like a BASE.
It uses streaming API to sync the entities.
In case of partition, both systems will be available, but not consistent
In case of no partition, the heroku connect try to sync as much as possible,
Conclusion
The distributed systems might and should be understanded by a lot of metrics
and terms, but the start point is it’s tradeoffs
It’s really difficult to classify an abstract system. You should decide what
kind of system do you want and then - look at what you can achieve
The 2 point is the reason why to find any good articles about that is not easy
either
Do not overwhelm yourself by that work, you should be a scientist to do it 99 %
correctly
All you didn't know about the CAP theorem
Links
https://dzone.com/articles/better-explaining-cap-theorem
https://martin.kleppmann.com/2015/05/11/please-stop-calling-databases-cp-or-ap.html
https://habrahabr.ru/post/231703/
http://blog.thislongrun.com/2015/03/the-confusing-cap-and-acid-wording.html
https://neo4j.com/blog/acid-vs-base-consistency-models-explained/
http://databases.about.com/od/databasetraining/a/databasesbegin.htm
https://brooker.co.za/blog/2014/07/16/pacelc.html
https://www.postgresql.org/files/developer/transactions.pdf
https://www.airpair.com/postgresql/posts/sql-vs-nosql-ko-postgres-vs-mongo
http://jennyxiaozhang.com/nosql-hbase-vs-cassandra-vs-mongodb/

More Related Content

What's hot (20)

PPTX
Microsoft azure backup overview
Sumantro Mukherjee
 
PDF
AWS Summit Seoul 2023 | Amazon Redshift Serverless를 활용한 LG 이노텍의 데이터 분석 플랫폼 혁신 과정
Amazon Web Services Korea
 
PDF
LG전자 - Amazon Aurora 및 RDS 블루/그린 배포를 이용한 데이터베이스 업그레이드 안정성 확보 - 발표자: 이은경 책임, L...
Amazon Web Services Korea
 
PPTX
AWS VS AZURE VS GCP.pptx
Raneesh Ramesan
 
PDF
데이터 분석플랫폼을 위한 데이터 전처리부터 시각화까지 한번에 보기 - 노인철 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul ...
Amazon Web Services Korea
 
PDF
Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...
Amazon Web Services Korea
 
PDF
AWS Summit Seoul 2023 | 바람을 예측하여 재생에너지 산업을 발전시키는 GS E&R의 새로운 여정
Amazon Web Services Korea
 
PDF
AWS Summit Seoul 2023 | 모두를 위한 BI, QuickSight
Amazon Web Services Korea
 
PPTX
Multi Cloud Architecture Approach
Maganathin Veeraragaloo
 
PPTX
Snowflake Architecture.pptx
chennakesava44
 
PDF
AWS Summit Seoul 2023 | Global scale service의 중앙 집중식 Observability 구축
Amazon Web Services Korea
 
PDF
[WhaTap DevOps Day] 세션 5 : 금융 Public 클라우드/ Devops 구축 여정
WhaTap Labs
 
PDF
AWS Summit Seoul 2023 | 새로운 금융 서비스 출시 시 Agility 확보 방안
Amazon Web Services Korea
 
ODP
Introduction to AWS IAM
Knoldus Inc.
 
PPTX
NoSQL and Couchbase
Sangharsh agarwal
 
PDF
AWS Summit Seoul 2023 | 당신만 모르고 있는 AWS 컨트롤 타워 트렌드
Amazon Web Services Korea
 
PDF
Cloud Migration: Moving Data and Infrastructure to the Cloud
Safe Software
 
PDF
AWS Summit Seoul 2023 | Amazon EKS, 중요한 건 꺾이지 않는 안정성
Amazon Web Services Korea
 
PPTX
Databricks for Dummies
Rodney Joyce
 
PDF
AWS Backup을 이용한 데이터베이스의 백업 자동화와 편리한 복구방법
Amazon Web Services Korea
 
Microsoft azure backup overview
Sumantro Mukherjee
 
AWS Summit Seoul 2023 | Amazon Redshift Serverless를 활용한 LG 이노텍의 데이터 분석 플랫폼 혁신 과정
Amazon Web Services Korea
 
LG전자 - Amazon Aurora 및 RDS 블루/그린 배포를 이용한 데이터베이스 업그레이드 안정성 확보 - 발표자: 이은경 책임, L...
Amazon Web Services Korea
 
AWS VS AZURE VS GCP.pptx
Raneesh Ramesan
 
데이터 분석플랫폼을 위한 데이터 전처리부터 시각화까지 한번에 보기 - 노인철 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul ...
Amazon Web Services Korea
 
Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...
Amazon Web Services Korea
 
AWS Summit Seoul 2023 | 바람을 예측하여 재생에너지 산업을 발전시키는 GS E&R의 새로운 여정
Amazon Web Services Korea
 
AWS Summit Seoul 2023 | 모두를 위한 BI, QuickSight
Amazon Web Services Korea
 
Multi Cloud Architecture Approach
Maganathin Veeraragaloo
 
Snowflake Architecture.pptx
chennakesava44
 
AWS Summit Seoul 2023 | Global scale service의 중앙 집중식 Observability 구축
Amazon Web Services Korea
 
[WhaTap DevOps Day] 세션 5 : 금융 Public 클라우드/ Devops 구축 여정
WhaTap Labs
 
AWS Summit Seoul 2023 | 새로운 금융 서비스 출시 시 Agility 확보 방안
Amazon Web Services Korea
 
Introduction to AWS IAM
Knoldus Inc.
 
NoSQL and Couchbase
Sangharsh agarwal
 
AWS Summit Seoul 2023 | 당신만 모르고 있는 AWS 컨트롤 타워 트렌드
Amazon Web Services Korea
 
Cloud Migration: Moving Data and Infrastructure to the Cloud
Safe Software
 
AWS Summit Seoul 2023 | Amazon EKS, 중요한 건 꺾이지 않는 안정성
Amazon Web Services Korea
 
Databricks for Dummies
Rodney Joyce
 
AWS Backup을 이용한 데이터베이스의 백업 자동화와 편리한 복구방법
Amazon Web Services Korea
 

Viewers also liked (10)

PDF
Cap in depth
Ioanna Tsalouchidou
 
PDF
NoSQL in Perspective
Jeff Smith
 
PPT
Rolling With Riak
John Lynch
 
PDF
Riak Core: Building Distributed Applications Without Shared State
Rusty Klophaus
 
KEY
Riak in Ten Minutes
Jon Meredith
 
KEY
Riak Training Session — Surge 2011
DstroyAllModels
 
PPTX
Что нового в nginx? / Максим Дунин (Nginx, Inc.)
Ontico
 
PPTX
NoSQL databases, the CAP theorem, and the theory of relativity
Lars Marius Garshol
 
PPTX
CAP Theorem - Theory, Implications and Practices
Yoav Francis
 
KEY
NoSQL Databases: Why, what and when
Lorenzo Alberton
 
Cap in depth
Ioanna Tsalouchidou
 
NoSQL in Perspective
Jeff Smith
 
Rolling With Riak
John Lynch
 
Riak Core: Building Distributed Applications Without Shared State
Rusty Klophaus
 
Riak in Ten Minutes
Jon Meredith
 
Riak Training Session — Surge 2011
DstroyAllModels
 
Что нового в nginx? / Максим Дунин (Nginx, Inc.)
Ontico
 
NoSQL databases, the CAP theorem, and the theory of relativity
Lars Marius Garshol
 
CAP Theorem - Theory, Implications and Practices
Yoav Francis
 
NoSQL Databases: Why, what and when
Lorenzo Alberton
 
Ad

Similar to All you didn't know about the CAP theorem (20)

PPTX
CAP: Scaling, HA
Vitaly Peregudov
 
PDF
A Critique of the CAP Theorem by Martin Kleppmann
mustafa sarac
 
KEY
Database Throwdown Introduction
Sean Collins
 
PDF
Lightning talk: highly scalable databases and the PACELC theorem
Vishal Bardoloi
 
PPT
CAP, PACELC, and Determinism
Daniel Abadi
 
PPTX
17-NoSQL.pptx
levichan1
 
ODP
Nosql availability & integrity
Fahri Firdausillah
 
PPTX
Cassandra & Python - Springfield MO User Group
Adam Hutson
 
PDF
Dsys guide37
Sattar kayani
 
PPTX
HbaseHivePigbyRohitDubey
Rohit Dubey
 
PDF
Database Consistency Models
Simon Ouellette
 
PDF
Distributed Algorithms
913245857
 
PDF
Lecture-04-Principles of data management.pdf
manimozhi98
 
PPTX
No sql (not only sql)
Priyodarshini Dhar
 
PPT
Container Independent failover framework - Mobicents Summit 2011
telestax
 
PPT
Container independent failover framework
telestax
 
PDF
Design Patterns For Distributed NO-reational databases
lovingprince58
 
PDF
Scalable Data Storage Getting you Down? To the Cloud!
Mikhail Panchenko
 
PDF
Scalable Data Storage Getting You Down? To The Cloud!
Mikhail Panchenko
 
PDF
Design Patterns for Distributed Non-Relational Databases
guestdfd1ec
 
CAP: Scaling, HA
Vitaly Peregudov
 
A Critique of the CAP Theorem by Martin Kleppmann
mustafa sarac
 
Database Throwdown Introduction
Sean Collins
 
Lightning talk: highly scalable databases and the PACELC theorem
Vishal Bardoloi
 
CAP, PACELC, and Determinism
Daniel Abadi
 
17-NoSQL.pptx
levichan1
 
Nosql availability & integrity
Fahri Firdausillah
 
Cassandra & Python - Springfield MO User Group
Adam Hutson
 
Dsys guide37
Sattar kayani
 
HbaseHivePigbyRohitDubey
Rohit Dubey
 
Database Consistency Models
Simon Ouellette
 
Distributed Algorithms
913245857
 
Lecture-04-Principles of data management.pdf
manimozhi98
 
No sql (not only sql)
Priyodarshini Dhar
 
Container Independent failover framework - Mobicents Summit 2011
telestax
 
Container independent failover framework
telestax
 
Design Patterns For Distributed NO-reational databases
lovingprince58
 
Scalable Data Storage Getting you Down? To the Cloud!
Mikhail Panchenko
 
Scalable Data Storage Getting You Down? To The Cloud!
Mikhail Panchenko
 
Design Patterns for Distributed Non-Relational Databases
guestdfd1ec
 
Ad

Recently uploaded (20)

PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 

All you didn't know about the CAP theorem

  • 1. All you didn’t know about the CAP theorem
  • 2. CAP theorem The theorem was presented on the Symposium on Principles of Distributed Computing in 2000 by Eric Brewer. In 2002, Seth Gilbert and Nancy Lynch of MIT published a formal proof of Brewer's conjecture, rendering it a theorem. According to Brewer, he wanted the community to start conversation about it, but his words have been corrected and treated as a theorem.
  • 3. What stands behind the cap? The CAP theorem states that in the distributed system you can choose only 2 out of 3: Consistency: every read would get you the most recent write Availability: every node (if not failed) always executes queries (read and writes) Partition-tolerance: even if the connections between nodes are down, the other two (A & C) promises, are kept.
  • 8. Let’s take a look at the postgresql Master/slave architecture is one of common solutions Slave can be synced with master in async/sync way The transaction system use two-phase commit to ensure consistency If a partition occurs you can’t talk to the server (in the basic case), the system is not CAP-available. So, it can’t continue work in case of network partitioning, but it provides strong consistency and high-availability. It’s a CA system!
  • 9. Let’s take a look at the mongodb MongoDB provides strong consistency, because it is a single-master system and all writes go to the primary by default MongoDB provides automatic failover in case of partitioning If a partition occurs it will stop accepting writes to the system until it believes that it can safely complete those writes. So, it can continue work in case of network partitioning and it gives up availability. It’s a CP system!
  • 10. Let’s take a look at the postgres + salesforce + heroku connect system It’s master-master system Heroku connect is responsible for keeping system consistency Salesforce data and our postgres db doesn’t know about each other If network partition occurs both storages will be available. Heroku connect will try to reconnect. So, it can continue work in case of network partitioning and it gives up consistency. It should be an AP system!
  • 11. It is so easy! Now I know everything!
  • 12. Actually, no. There are a lot of problems with CAP theorem: CAP uses very narrow and far-from-the-real-world definitions Actually, it is the choice only between consistency and availability Many systems are neither CAP-consistent nor CAP-available Pure AP systems are useless Pure CP systems might behave not as expected
  • 13. What is wrong with definitions Consistency in CAP actually means linearizability (and it’s really hard to reach it). Availability in CAP is defined as “every request received by a non-failing [database] node in the system must result in a [non-error] response” and it’s not restricted by time. The only fault considered by the CAP theorem is a network partition.
  • 15. Why node failures are outside CAP? By the definition of availability: ...every node (if not failed) always... By the proof of CAP: the proof of CAP used by Gilbert and Lynch relies on having code running on both sides of the partition. In some cases, a partition will be equivalent to a failure, but this equivalence will be obtained by implementing a specific logic in all the nodes. Of course, we should manage node failures, but CAP doesn’t help us here.
  • 16. AP / CP choice Partition Tolerance basically means that you’re communicating over an asynchronous network that may delay or drop messages. The internet and all our data centers have this property, so you don’t really have any choice in this matter.
  • 17. Many systems are only “p” In case you have one master and one slave, and you are partitioned from the master - you can’t write, but you can read. It’s not CAP-available. Ok, it’s a CP system, but usually sync between slave and master is async and there might be a gap between sync and system partitioning, so you do not have CAP-consistency.
  • 18. AP and CP problems Pure AP is useless, it may just return any random value and it would be an AP system Pure CP is useless too, because partitioning in CAP have no fixed duration, so the system provides only eventual consistency, which is not the strong one that we want to have.
  • 20. How to describe distributed system Remember about CAP narrow definitions, as they are still widely used Use PACELC(A) theorem instead of CAP, it provides additional consistency/latency tradeoff Describe how ACID/BASE principles apply to your system Decide if the system suits your needs, considering the project you are working on.
  • 21. Let’s take a look on PACELC(A) The PACELC theorem was first described and formalised by Daniel J. Abadi from Yale University in 2012. IF there is a partition (P), how does the system tradeoff availability and consistency (A and C) ELSE (E) When the system is running normally in the absence of partitions, how does the system trade off latency (L) and consistency (C)? As PACELC theorem is based on CAP, it also uses CAP definitions.
  • 23. Let’s take a look on ACID ACID - is a set of properties of database transactions. Jim Gray defined these properties of a reliable transaction system in the late 1970s and developed technologies to achieve them automatically. Database vendors long time ago introduced 2 phase commit for providing ACID across multiple database instances.
  • 24. Let’s take a look on ACID Atomicity. All of the operations in the transaction will complete, or none will Consistency. The database will be in a consistent state when the transaction begins and ends Isolation. The transaction will behave as if it is the only operation being performed upon the database Durability. Once a transaction has been committed, it will remain so, even in the event of power loss, crashes, or errors.
  • 25. CAP/ACID definition confusion Consistency in ACID relates to data integrity, whereas Consistency in CAP is a reference for Atomic Consistency (Linearizability), which is a consistency model Isolation term is not used in CAP, but it’s definition in ACID is actually the same for what linearizability stands for Availability in ACID is not used in definitions, but when it’s presented in articles, it means the same as CAP-availability, apart that it’s not required for all non-failing nodes to respond.
  • 26. Let’s take a look on BASE Eventually consistent services are often classified as providing BASE semantics, in contrast to traditional ACID guarantees. One of the earliest definitions of eventual consistency comes from a 1988. BASE essentially embraces the fact that true consistency cannot be achieved in the real world, and as such cannot be modelled in highly scalable distributed systems.
  • 27. What is BASE Basic Availability states that there will be a response to any request, but, that response could still be a “failure” or the data may be in an inconsistent or changing state Soft-state state of the system could change over time due to “eventual consistency” changes Eventual consistency states that the system will eventually become consistent, the system will continue to receive input and is not checking the consistency of every transaction before it moves onto the next one
  • 28. Try to digest it too...
  • 29. Fresh look on the postgres Postgres does allow multiple cluster configuration, so it’s really hard to describe all of them. Let’s just take the master - slave replication with the Slony implementation. The system works according ACID (there are couple of problems with two-phase commit, but mostly it’s reliable) In case of partition the Slony will try to proceed switchover and if all went fine, we have our new master with its consistency When there is no partition the Slony gives up latency and does everything to approach strong consistency. Actually, ACID is the reason off high latency The system is considered as PC/EC(A)
  • 30. Fresh look on the mongodb MongoDB is a NOSQL database. MongoDB is ACID in limited sense at the document level In case of distributed system - it’s all about BASE In case of no partition, the system guarantees reads and writes to be consistent If the master node will be failed or partitioned from the rest of the system, some data will not be replicated. System elects a new master to remain available for reads and writes.(New master and old master are inconsistent) The system is considered as PA/EC(A), as most of the nodes remain CAP-available in case of partition.
  • 31. fresh look on the postgres + salesforce + heroku connect system The Salesforce is an abstraction to oracle database (RDBMS) and the Postgres is an actual RDBMS. Heroku connect is a tool to sync those too dbs. Let’s see what we have… Heroku connect, Postgres and Salesforce provide us ACID, but we can’t operate with related entities Surprise! The full system looks more like a BASE. It uses streaming API to sync the entities. In case of partition, both systems will be available, but not consistent In case of no partition, the heroku connect try to sync as much as possible,
  • 32. Conclusion The distributed systems might and should be understanded by a lot of metrics and terms, but the start point is it’s tradeoffs It’s really difficult to classify an abstract system. You should decide what kind of system do you want and then - look at what you can achieve The 2 point is the reason why to find any good articles about that is not easy either Do not overwhelm yourself by that work, you should be a scientist to do it 99 % correctly
  • 34. Links https://dzone.com/articles/better-explaining-cap-theorem https://martin.kleppmann.com/2015/05/11/please-stop-calling-databases-cp-or-ap.html https://habrahabr.ru/post/231703/ http://blog.thislongrun.com/2015/03/the-confusing-cap-and-acid-wording.html https://neo4j.com/blog/acid-vs-base-consistency-models-explained/ http://databases.about.com/od/databasetraining/a/databasesbegin.htm https://brooker.co.za/blog/2014/07/16/pacelc.html https://www.postgresql.org/files/developer/transactions.pdf https://www.airpair.com/postgresql/posts/sql-vs-nosql-ko-postgres-vs-mongo http://jennyxiaozhang.com/nosql-hbase-vs-cassandra-vs-mongodb/

Editor's Notes

  • #2: Спросить эксперта в зале и попросить его внимательно следить и в конце поправить?
  • #3: Кто слышал про CAP теорему? А кто использовал её?
  • #12: Что осталось не ясно?
  • #15: Linearizability gives isolation at the level of operations. This is a fairly expensive guarantee to provide, because it requires a lot of coordination. Even the CPU in your computer doesn’t provide linearizable access to your local RAM! On modern CPUs, you need to use an explicit memory barrier instruction in order to get linearizability. And even testing whether a system provides linearizability is tricky.
  • #20: Вопросы?
  • #29: Вопросы?
  • #34: Вопросы?