SlideShare a Scribd company logo
1 of 36
Download to read offline
Franz Wimmer
franz.wimmer@qaware.de
@zalintyre
Consistency, Availability and
Partition tolerance in practice
A deep dive into CockroachDB
15.01.2020
Franz Wimmer
Software Engineer
2019
2018
2017
- No Backend, no Problem! Static Websites with Jekyll
- Offensive Security – The Metasploit Framework
@QAware
- Evaluating private APIs with Apache Ignite
@MRMCD, Darmstadt
- Leveraging the power of SolrCloud and Spark with OpenShift
@Munich Kubernetes / Cloud Native Meetup
- Ransomware vs. Antivirus
@ MRMCD, Darmstadt
1. Introduction
2. CAP Theorem
3. CockroachDB
4. Live Demo
5. Summary
Introduction
Many database systems offer some sort of distribution or replication. Choose wisely:
Distribution / Sharding:
Data is partitioned across multiple nodes.
Less availability in case of outages.
Reads are quite fast and easy to achieve.
Replication:
Data is copied to multiple nodes.
More availability in case of outages.
Writes are difficult to replicate consistently.
Examples:
MySQL Master / Slave (replicated, slave read only)
PostgreSQL High Availability / Load Balancing / Replication (replicated)
MongoDB, CouchDB (Shards & Replicas)
Solr Cloud (Shards & Replicas)
Introduction – Distributed / Replicated Databases
CAP Theorem
“In a network subject to communication failures, it
is impossible for any web service to implement an
atomic read/write shared memory that
guarantees a response to every request” 1
1
Gilbert, Seth, and Nancy Lynch. "Perspectives on the CAP Theorem." Computer 45.2 (2012): 30-36.
The CAP Theorem
8
Consistency Availability
Partition tolerance
x
All nodes see the exact
same copies of data at a
given time.
C A
P
The system is still available, even if
nodes or communication paths go
offline.
The system works even if messages are lost.
It can deal with the network splitting up in
several partitions.
AP: DNS
Highly available
Arbitrary servers can go offline
Consistency takes a long time (up to 24 hours)
CP: (Online) Banking
Consistency is key, even when the network is down
Availability is secondary
CA: RDBMS with highly available servers and networks
Consistent (transactions) and highly available
Fail when outages occur
Examples
“CockroachDB chooses
consistency.”
“CockroachDB chooses consistency”
As a CP system, is CockroachDB not available? No!
Every piece of data (“range”) is replicated to at least 3 nodes.
In this setup, up to 2 nodes can go offline / be partitioned away.
But: Writes require a majority of replicas to be available.
CockroachDB and the CAP Theorem
In the cloud, communication failures are
common. So basically, you have the choice
between CP and AP.
The CAP Theorem (2)
Consistency Availability
Partition tolerance
x
C A
P
2PC2PC
GossipGossipConsensusConsensus
CockroachDB uses RAFT as consensus protocol.
RAFT
CockroachDB
CockroachDB is …
A distributed SQL database
Every SQL query operates on key-value data.
Data is persisted using RocksDB key-value store.
Raft is the central consensus algorithm to manage the database cluster.
CockroachDB architecture defines layers:
SQL
Transaction
Distribution
Replication
Storage
CockroachDB Architecture
Range: A chunk of data. Think of “SQL Table”.
Replica: Each range is copied to (at least) 3 different nodes.
Leaseholder: The replica that coordinates reads and writes for a range.
Glossary
SQL – Read data
SQL – Read data
SQL – Write data
SQL – Write data
CockroachDB supports ACID transactions.
Atomicity
Writes are performed to the whole cluster at once.
If anything fails, the transaction is rolled back.
Consistency
Incomplete write operations are at no time served to reading clients.
Isolation
All CockroachDB transactions are upgraded to SERIALIZABLE.
Durability
Every successful transaction has been persisted to a majority of replicas (see: Raft).
Transactions
Distribution & Replication
Distribution & Replication
Distribution & Replication
CockroachDB was built around …
… the SQL network protocol (“pgwire”)
… the SQL syntax (“using the PostgreSQL syntax parser”)
… and the SQL dialect semantics
of PostgreSQL.
This means that you can …
… use a standard PostgreSQL driver
… build the same SQL Queries you always did
… or use a SQL framework of your choice (Hibernate, EclipseLink, …)
… well, that’s not entirely true.
CockroachDB doesn’t support some PostgreSQL features
… and might implement own features in the future.
PostgreSQL compatibility
Deploying is easy with various cloud providers
YAML files for every occasion
Different Helm charts available
Deployment
$ wget -qO- https://binaries.cockroachdb.com/cockroach-v19.2.4.linux-amd64.tgz | tar xvz
$ cp -i cockroach-v19.2.4.linux-amd64/cockroach /usr/local/bin/
$ cockroach start
Deployment – the easiest way
Demo time!
Source Code
available here:
https://github.com/zalintyre/cockroach-demo.git
Summary
Performance
Performance
Easy to install
Easy to use (Postgres driver!)
Don‘t worry about consistency, but prepare for occasional waits
Open Source
Free (if you don‘t need enterprise features)
Maybe this is the PostgreSQL database you always wanted.
Summary
QAware 34
Core Edition
Licensed under Apache 2.0 until version 19.1
From 19.2: Business Source License (BSL)
Forbids you to host CockroachDB as a Service.
Converts to Apache 2.0 license three years after release
Enterprise Edition: Geo partitioning, RBAC, Follower Reads, Encryption at Rest...
There are a lot more features not covered by this talk!
Licensing and features
CockroachDB docs: https://www.cockroachlabs.com/docs/stable
RAFT visualization: http://thesecretlivesofdata.com/raft/
See also
twitter.com/zalintyre github.com/zalintyreFranz Wimmer
franz.wimmer@qaware.de

More Related Content

More from QAware GmbH

Cloud Migration mit KI: der Turbo
Cloud Migration mit KI: der Turbo Cloud Migration mit KI: der Turbo
Cloud Migration mit KI: der Turbo QAware GmbH
 
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
 Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See... Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...QAware GmbH
 
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster QAware GmbH
 
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.QAware GmbH
 
Kubernetes with Cilium in AWS - Experience Report!
Kubernetes with Cilium in AWS - Experience Report!Kubernetes with Cilium in AWS - Experience Report!
Kubernetes with Cilium in AWS - Experience Report!QAware GmbH
 
50 Shades of K8s Autoscaling
50 Shades of K8s Autoscaling50 Shades of K8s Autoscaling
50 Shades of K8s AutoscalingQAware GmbH
 
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAP
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAPKontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAP
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAPQAware GmbH
 
Service Mesh Pain & Gain. Experiences from a client project.
Service Mesh Pain & Gain. Experiences from a client project.Service Mesh Pain & Gain. Experiences from a client project.
Service Mesh Pain & Gain. Experiences from a client project.QAware GmbH
 
50 Shades of K8s Autoscaling
50 Shades of K8s Autoscaling50 Shades of K8s Autoscaling
50 Shades of K8s AutoscalingQAware GmbH
 
Blue turns green! Approaches and technologies for sustainable K8s clusters.
Blue turns green! Approaches and technologies for sustainable K8s clusters.Blue turns green! Approaches and technologies for sustainable K8s clusters.
Blue turns green! Approaches and technologies for sustainable K8s clusters.QAware GmbH
 
Per Anhalter zu Cloud Nativen API Gateways
Per Anhalter zu Cloud Nativen API GatewaysPer Anhalter zu Cloud Nativen API Gateways
Per Anhalter zu Cloud Nativen API GatewaysQAware GmbH
 
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster QAware GmbH
 
How to speed up Spring Integration Tests
How to speed up Spring Integration TestsHow to speed up Spring Integration Tests
How to speed up Spring Integration TestsQAware GmbH
 
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-ClusterAus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-ClusterQAware GmbH
 
Cloud Migration – Eine Strategie die funktioniert
Cloud Migration – Eine Strategie die funktioniertCloud Migration – Eine Strategie die funktioniert
Cloud Migration – Eine Strategie die funktioniertQAware GmbH
 
Policy Driven Microservices mit Open Policy Agent
Policy Driven Microservices mit Open Policy AgentPolicy Driven Microservices mit Open Policy Agent
Policy Driven Microservices mit Open Policy AgentQAware GmbH
 
Make Developers Fly: Principles for Platform Engineering
Make Developers Fly: Principles for Platform EngineeringMake Developers Fly: Principles for Platform Engineering
Make Developers Fly: Principles for Platform EngineeringQAware GmbH
 
Security Lab: OIDC in der Praxis
Security Lab: OIDC in der PraxisSecurity Lab: OIDC in der Praxis
Security Lab: OIDC in der PraxisQAware GmbH
 
Die nächsten 100 Microservices
Die nächsten 100 MicroservicesDie nächsten 100 Microservices
Die nächsten 100 MicroservicesQAware GmbH
 
Enterprise-level Kubernetes Security mit Open Source Tools - geht das?
Enterprise-level Kubernetes Security mit Open Source Tools - geht das?Enterprise-level Kubernetes Security mit Open Source Tools - geht das?
Enterprise-level Kubernetes Security mit Open Source Tools - geht das?QAware GmbH
 

More from QAware GmbH (20)

Cloud Migration mit KI: der Turbo
Cloud Migration mit KI: der Turbo Cloud Migration mit KI: der Turbo
Cloud Migration mit KI: der Turbo
 
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
 Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See... Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
 
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
 
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.
 
Kubernetes with Cilium in AWS - Experience Report!
Kubernetes with Cilium in AWS - Experience Report!Kubernetes with Cilium in AWS - Experience Report!
Kubernetes with Cilium in AWS - Experience Report!
 
50 Shades of K8s Autoscaling
50 Shades of K8s Autoscaling50 Shades of K8s Autoscaling
50 Shades of K8s Autoscaling
 
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAP
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAPKontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAP
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAP
 
Service Mesh Pain & Gain. Experiences from a client project.
Service Mesh Pain & Gain. Experiences from a client project.Service Mesh Pain & Gain. Experiences from a client project.
Service Mesh Pain & Gain. Experiences from a client project.
 
50 Shades of K8s Autoscaling
50 Shades of K8s Autoscaling50 Shades of K8s Autoscaling
50 Shades of K8s Autoscaling
 
Blue turns green! Approaches and technologies for sustainable K8s clusters.
Blue turns green! Approaches and technologies for sustainable K8s clusters.Blue turns green! Approaches and technologies for sustainable K8s clusters.
Blue turns green! Approaches and technologies for sustainable K8s clusters.
 
Per Anhalter zu Cloud Nativen API Gateways
Per Anhalter zu Cloud Nativen API GatewaysPer Anhalter zu Cloud Nativen API Gateways
Per Anhalter zu Cloud Nativen API Gateways
 
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
 
How to speed up Spring Integration Tests
How to speed up Spring Integration TestsHow to speed up Spring Integration Tests
How to speed up Spring Integration Tests
 
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-ClusterAus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
 
Cloud Migration – Eine Strategie die funktioniert
Cloud Migration – Eine Strategie die funktioniertCloud Migration – Eine Strategie die funktioniert
Cloud Migration – Eine Strategie die funktioniert
 
Policy Driven Microservices mit Open Policy Agent
Policy Driven Microservices mit Open Policy AgentPolicy Driven Microservices mit Open Policy Agent
Policy Driven Microservices mit Open Policy Agent
 
Make Developers Fly: Principles for Platform Engineering
Make Developers Fly: Principles for Platform EngineeringMake Developers Fly: Principles for Platform Engineering
Make Developers Fly: Principles for Platform Engineering
 
Security Lab: OIDC in der Praxis
Security Lab: OIDC in der PraxisSecurity Lab: OIDC in der Praxis
Security Lab: OIDC in der Praxis
 
Die nächsten 100 Microservices
Die nächsten 100 MicroservicesDie nächsten 100 Microservices
Die nächsten 100 Microservices
 
Enterprise-level Kubernetes Security mit Open Source Tools - geht das?
Enterprise-level Kubernetes Security mit Open Source Tools - geht das?Enterprise-level Kubernetes Security mit Open Source Tools - geht das?
Enterprise-level Kubernetes Security mit Open Source Tools - geht das?
 

Recently uploaded

20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...Amil Baba Dawood bangali
 
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...GQ Research
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]📊 Markus Baersch
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryJeremy Anderson
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfBoston Institute of Analytics
 
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...limedy534
 
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...ssuserf63bd7
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Colleen Farrelly
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 217djon017
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理e4aez8ss
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queensdataanalyticsqueen03
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Seán Kennedy
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一fhwihughh
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024thyngster
 

Recently uploaded (20)

20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
 
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data Story
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
 
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
 
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queens
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
 

Consistency, Availability and Partition tolerance in practice

  • 1. Franz Wimmer franz.wimmer@qaware.de @zalintyre Consistency, Availability and Partition tolerance in practice A deep dive into CockroachDB 15.01.2020
  • 2. Franz Wimmer Software Engineer 2019 2018 2017 - No Backend, no Problem! Static Websites with Jekyll - Offensive Security – The Metasploit Framework @QAware - Evaluating private APIs with Apache Ignite @MRMCD, Darmstadt - Leveraging the power of SolrCloud and Spark with OpenShift @Munich Kubernetes / Cloud Native Meetup - Ransomware vs. Antivirus @ MRMCD, Darmstadt
  • 3. 1. Introduction 2. CAP Theorem 3. CockroachDB 4. Live Demo 5. Summary
  • 5. Many database systems offer some sort of distribution or replication. Choose wisely: Distribution / Sharding: Data is partitioned across multiple nodes. Less availability in case of outages. Reads are quite fast and easy to achieve. Replication: Data is copied to multiple nodes. More availability in case of outages. Writes are difficult to replicate consistently. Examples: MySQL Master / Slave (replicated, slave read only) PostgreSQL High Availability / Load Balancing / Replication (replicated) MongoDB, CouchDB (Shards & Replicas) Solr Cloud (Shards & Replicas) Introduction – Distributed / Replicated Databases
  • 7. “In a network subject to communication failures, it is impossible for any web service to implement an atomic read/write shared memory that guarantees a response to every request” 1 1 Gilbert, Seth, and Nancy Lynch. "Perspectives on the CAP Theorem." Computer 45.2 (2012): 30-36.
  • 8. The CAP Theorem 8 Consistency Availability Partition tolerance x All nodes see the exact same copies of data at a given time. C A P The system is still available, even if nodes or communication paths go offline. The system works even if messages are lost. It can deal with the network splitting up in several partitions.
  • 9. AP: DNS Highly available Arbitrary servers can go offline Consistency takes a long time (up to 24 hours) CP: (Online) Banking Consistency is key, even when the network is down Availability is secondary CA: RDBMS with highly available servers and networks Consistent (transactions) and highly available Fail when outages occur Examples
  • 11. “CockroachDB chooses consistency” As a CP system, is CockroachDB not available? No! Every piece of data (“range”) is replicated to at least 3 nodes. In this setup, up to 2 nodes can go offline / be partitioned away. But: Writes require a majority of replicas to be available. CockroachDB and the CAP Theorem
  • 12. In the cloud, communication failures are common. So basically, you have the choice between CP and AP. The CAP Theorem (2) Consistency Availability Partition tolerance x C A P 2PC2PC GossipGossipConsensusConsensus
  • 13. CockroachDB uses RAFT as consensus protocol. RAFT
  • 15. CockroachDB is … A distributed SQL database Every SQL query operates on key-value data. Data is persisted using RocksDB key-value store. Raft is the central consensus algorithm to manage the database cluster. CockroachDB architecture defines layers: SQL Transaction Distribution Replication Storage CockroachDB Architecture
  • 16. Range: A chunk of data. Think of “SQL Table”. Replica: Each range is copied to (at least) 3 different nodes. Leaseholder: The replica that coordinates reads and writes for a range. Glossary
  • 17. SQL – Read data
  • 18. SQL – Read data
  • 21. CockroachDB supports ACID transactions. Atomicity Writes are performed to the whole cluster at once. If anything fails, the transaction is rolled back. Consistency Incomplete write operations are at no time served to reading clients. Isolation All CockroachDB transactions are upgraded to SERIALIZABLE. Durability Every successful transaction has been persisted to a majority of replicas (see: Raft). Transactions
  • 25. CockroachDB was built around … … the SQL network protocol (“pgwire”) … the SQL syntax (“using the PostgreSQL syntax parser”) … and the SQL dialect semantics of PostgreSQL. This means that you can … … use a standard PostgreSQL driver … build the same SQL Queries you always did … or use a SQL framework of your choice (Hibernate, EclipseLink, …) … well, that’s not entirely true. CockroachDB doesn’t support some PostgreSQL features … and might implement own features in the future. PostgreSQL compatibility
  • 26. Deploying is easy with various cloud providers YAML files for every occasion Different Helm charts available Deployment
  • 27. $ wget -qO- https://binaries.cockroachdb.com/cockroach-v19.2.4.linux-amd64.tgz | tar xvz $ cp -i cockroach-v19.2.4.linux-amd64/cockroach /usr/local/bin/ $ cockroach start Deployment – the easiest way
  • 33. Easy to install Easy to use (Postgres driver!) Don‘t worry about consistency, but prepare for occasional waits Open Source Free (if you don‘t need enterprise features) Maybe this is the PostgreSQL database you always wanted. Summary
  • 34. QAware 34 Core Edition Licensed under Apache 2.0 until version 19.1 From 19.2: Business Source License (BSL) Forbids you to host CockroachDB as a Service. Converts to Apache 2.0 license three years after release Enterprise Edition: Geo partitioning, RBAC, Follower Reads, Encryption at Rest... There are a lot more features not covered by this talk! Licensing and features
  • 35. CockroachDB docs: https://www.cockroachlabs.com/docs/stable RAFT visualization: http://thesecretlivesofdata.com/raft/ See also