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

Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystSamantha Rae Coolbeth
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxolyaivanovalion
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 

Recently uploaded (20)

Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data Analyst
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 

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