SlideShare a Scribd company logo
No C-QL
(Or how I learned to stop worrying, and love
eventual consistency)
Brian Brazil
Senior Software Engineer
Boxever
Overview
NoSQL and eventual consistency are
complementary.
Why would you need it, how do you take
advantage of it, and when is it useful in
distributed systems?
A Simple Example
Website that counts how many times a user
visits the site, and each page.
First visit
User Total Count
Brian 1
User Page Count
Brian index 1
Webserver DB
index
Read Old Total Count
Insert New Total Count
Read Count
Insert New Count
DB
DB
Second visit
User Total Count
Brian 2
User Page Count
Brian index 1
Brian sales 1
Webserver
sales
Read Old Total Count
Update New Total Count
Read Count
Insert New Count
DB
DB
DB
What do you think?
Initial thoughts
Looks like a simple, obvious solution
Tabbed Browsing
Tabbed Browsing
Webserver
A: Read Old Total Count
B: Read Old Total Count
A: Update New Total Count
B: Update New Total Count
.
.
.
Webserversales
index
DB
DB
DB
Tabbed Browsing
User Total Count
Brian 3
User Page Count
Brian index 2
Brian sales 2
Webserver
A: Read Old Total Count
B: Read Old Total Count
A: Update New Total Count
B: Update New Total Count
.
.
.
Webserversales
index
DB
DB
DB
What happened?
Concurrent updates clashed.
Need to protect against that.
ACID to the rescue!
● Apply each set of updates atomically
● Updates don’t interfere with each other
ACID to the rescue?
● Bottleneck for writes
● Webserver needs to retry
● Databases need to coordinate for quorum
Aside: Cost of Reads
● Hard disk seek: 5 - 10ms
Aside: Cost of Reads
● Hard disk seek: 5 - 10ms
● Cluster quorum read: 1 - 200ms
Aside: Cost of Reads
● Hard disk seek: 5 - 10ms
● Cluster quorum read: 1 - 200ms
● RTT to webserver: 1 - 200ms
Aside: Cost of Reads
● Hard disk seek: 5 - 10ms
● Cluster quorum read: 1 - 200ms
● RTT to webserver: 1 - 200ms
Avoid reads on the write path.
Eventual consistency
Being slightly out of date doesn’t matter for
many applications.
Can we take advantage of this to avoid
bottlenecks and latency?
First visit
User UniqueID Page
Brian 1409778671-Server1-PID index
Webserver DB
index Insert Visit
DB
DB
Second visit
User UniqueID Page
Brian 1409778671-Server1-PID index
Brian 1409778689-Server1-PID sales
Webserver DB
sales Insert Visit
DB
DB
Tabbed Browsing
User UniqueID Page
Brian 1409778671-Server1-PID index
Brian 1409778689-Server1-PID sales
Brian 1409778691-Server1-PID index
Brian 1409778691-Server2-PID sales
DB
A: Insert Visit
B: Insert Visit
DB
DB
Webserver
Webserversales
index
Analysis
● Unique IDs avoid clashes
● No bottlenecks due to consistency
● Data always internally consistent
● Fire & forget
● Only need to talk to nearest database(s)
● Resilient to network partitions
Not all good
● Reads have to look at more data
● Need to make sure data makes it
everywhere
● What if something depends on having data
up to time X?
NoSQL?
Everything thus far applies equally to relational
and non-relational databases.
NoSQL Advantage
● Data locality on disk, multiple entries per row
● Replication options beyond master/slave
● Writes are cheap
● Can also have consistency where needed
When is it good?
● Writes dominate
● Need high throughput and scalability
● Inter/intra continental databases
● 100% correct data in realtime not essential
When is it not so good?
● Writes are relatively rare
● Scale isn’t a concern
● Data must be completely consistent
Idempotency
Each entry is unique, so can be safely replayed
again and again.
Gives you options for disaster recovery:
Log requests to local webserver disk, replay if
database goes down
Improvements
● Take advantage of entry ordering
● Do rollups as a batch task
○ Reduces data to be processed, cutting latency
● Row per day/week/month
○ Avoids rows getting too big
● Handling updates and deletes
○ Can be done using only puts
Advanced
This is a very simple example, only doing a
count.
For more see
“Extreme availability and self-healing data with
CRDTs” at 11am with Uwe Friedrichsen in
Room 2
Summary
Consistency brings bottlenecks.
Eventual consistency allows for high-
throughput, reliable writes.
NoSQL combined with eventual consistency
can scale very well.
Questions?

More Related Content

PDF
Prometheus lightning talk (Devops Dublin March 2015)
PDF
Monitoring Hadoop with Prometheus (Hadoop User Group Ireland, December 2015)
PDF
Provisioning and Capacity Planning Workshop (Dogpatch Labs, September 2015)
PPTX
Prometheus design and philosophy
PDF
Systems Monitoring with Prometheus (Devops Ireland April 2015)
PDF
Ansible at FOSDEM (Ansible Dublin, 2016)
PDF
Prometheus and Docker (Docker Galway, November 2015)
PDF
Prometheus: A Next Generation Monitoring System (FOSDEM 2016)
Prometheus lightning talk (Devops Dublin March 2015)
Monitoring Hadoop with Prometheus (Hadoop User Group Ireland, December 2015)
Provisioning and Capacity Planning Workshop (Dogpatch Labs, September 2015)
Prometheus design and philosophy
Systems Monitoring with Prometheus (Devops Ireland April 2015)
Ansible at FOSDEM (Ansible Dublin, 2016)
Prometheus and Docker (Docker Galway, November 2015)
Prometheus: A Next Generation Monitoring System (FOSDEM 2016)

What's hot (20)

PPTX
Prometheus on AWS
PDF
Introduction to Prometheus and Cortex (WOUG)
PDF
The Open-Source Monitoring Landscape
PDF
Monitoring microservices with Prometheus
PDF
Scaling Up with PHP and AWS
PPTX
Prometheus for Monitoring Metrics (Fermilab 2018)
PPTX
Reactive Streams
KEY
Caching: A Guided Tour - 10/12/2010
PPTX
Determinism in finance
PDF
Prometheus Introduction (InfraCoders Vienna)
PPTX
Realtime classroom analytics powered by apache druid
PDF
Illuminate - Performance Analystics driven by Machine Learning
PDF
kranonit S06E01 Игорь Цинько: High load
PDF
Дмитро Волошин "High[Page]load"
PPTX
Altitude SF 2017: Reddit - How we built and scaled r/place
PDF
Data on its way to history, interrupted by analytics and silicon (@pavlobaron)
ODP
Open Source Monitoring Tools Shootout
PDF
Александр Махомет "Beyond the code или как мониторить ваш PHP сайт"
PDF
Important Factors that bring down the trading systems projects
Prometheus on AWS
Introduction to Prometheus and Cortex (WOUG)
The Open-Source Monitoring Landscape
Monitoring microservices with Prometheus
Scaling Up with PHP and AWS
Prometheus for Monitoring Metrics (Fermilab 2018)
Reactive Streams
Caching: A Guided Tour - 10/12/2010
Determinism in finance
Prometheus Introduction (InfraCoders Vienna)
Realtime classroom analytics powered by apache druid
Illuminate - Performance Analystics driven by Machine Learning
kranonit S06E01 Игорь Цинько: High load
Дмитро Волошин "High[Page]load"
Altitude SF 2017: Reddit - How we built and scaled r/place
Data on its way to history, interrupted by analytics and silicon (@pavlobaron)
Open Source Monitoring Tools Shootout
Александр Махомет "Beyond the code или как мониторить ваш PHP сайт"
Important Factors that bring down the trading systems projects
Ad

Similar to No C-QL (Or how I learned to stop worrying, and love eventual consistency) (NoSQL Matters September 2014) (20)

PPTX
Writing Low Latency Database Applications Even If Your Code Sucks
PDF
EVCache: Lowering Costs for a Low Latency Cache with RocksDB
PPTX
Handling Data in Mega Scale Systems
PDF
Cloud arch patterns
PDF
Netflix Open Source Meetup Season 4 Episode 2
PPTX
Maximizing performance via tuning and optimization
PPTX
Maximizing performance via tuning and optimization
PDF
OSMC 2019 | How to improve database Observability by Charles Judith
PDF
Performance Measurements: Improving Latency and Bandwidth of your DDR4 System
PPTX
Day 2 General Session Presentations RedisConf
PDF
MongoDB: What, why, when
PDF
MongoDB World 2019: Packing Up Your Data and Moving to MongoDB Atlas
PDF
Polyglot Persistence - Two Great Tastes That Taste Great Together
PDF
Building a High Performance Analytics Platform
PPTX
Hardware planning & sizing for sql server
PDF
A Day in the Life of a Druid Implementor and Druid's Roadmap
PPTX
Management and Automation of MongoDB Clusters - Slides
PDF
Data Science in the Cloud @StitchFix
PDF
#OSSPARIS19 - How to improve database observability - CHARLES JUDITH, Criteo
PDF
Tales from Taming the Long Tail
Writing Low Latency Database Applications Even If Your Code Sucks
EVCache: Lowering Costs for a Low Latency Cache with RocksDB
Handling Data in Mega Scale Systems
Cloud arch patterns
Netflix Open Source Meetup Season 4 Episode 2
Maximizing performance via tuning and optimization
Maximizing performance via tuning and optimization
OSMC 2019 | How to improve database Observability by Charles Judith
Performance Measurements: Improving Latency and Bandwidth of your DDR4 System
Day 2 General Session Presentations RedisConf
MongoDB: What, why, when
MongoDB World 2019: Packing Up Your Data and Moving to MongoDB Atlas
Polyglot Persistence - Two Great Tastes That Taste Great Together
Building a High Performance Analytics Platform
Hardware planning & sizing for sql server
A Day in the Life of a Druid Implementor and Druid's Roadmap
Management and Automation of MongoDB Clusters - Slides
Data Science in the Cloud @StitchFix
#OSSPARIS19 - How to improve database observability - CHARLES JUDITH, Criteo
Tales from Taming the Long Tail
Ad

More from Brian Brazil (20)

PPTX
OpenMetrics: What Does It Mean for You (PromCon 2019, Munich)
PPTX
Evolution of Monitoring and Prometheus (Dublin 2018)
PPTX
Evaluating Prometheus Knowledge in Interviews (PromCon 2018)
PPTX
Anatomy of a Prometheus Client Library (PromCon 2018)
PPTX
Evolving Prometheus for the Cloud Native World (FOSDEM 2018)
PPTX
Prometheus for Monitoring Metrics (Percona Live Europe 2017)
PPTX
Evolution of the Prometheus TSDB (Percona Live Europe 2017)
PPTX
Staleness and Isolation in Prometheus 2.0 (PromCon 2017)
PPTX
Rule 110 for Prometheus (PromCon 2017)
PPTX
Counting with Prometheus (CloudNativeCon+Kubecon Europe 2017)
PPTX
Prometheus: From Berlin to Bonanza (Keynote CloudNativeCon+Kubecon Europe 2017)
PPTX
What does "monitoring" mean? (FOSDEM 2017)
PPTX
An Introduction to Prometheus (GrafanaCon 2016)
PPTX
Provisioning and Capacity Planning (Travel Meets Big Data)
PPTX
Prometheus - Open Source Forum Japan
PPTX
Monitoring What Matters: The Prometheus Approach to Whitebox Monitoring (Berl...
PPTX
So You Want to Write an Exporter
PPTX
An Exploration of the Formal Properties of PromQL
PPTX
Life of a Label (PromCon2016, Berlin)
PPTX
Prometheus (Prometheus London, 2016)
OpenMetrics: What Does It Mean for You (PromCon 2019, Munich)
Evolution of Monitoring and Prometheus (Dublin 2018)
Evaluating Prometheus Knowledge in Interviews (PromCon 2018)
Anatomy of a Prometheus Client Library (PromCon 2018)
Evolving Prometheus for the Cloud Native World (FOSDEM 2018)
Prometheus for Monitoring Metrics (Percona Live Europe 2017)
Evolution of the Prometheus TSDB (Percona Live Europe 2017)
Staleness and Isolation in Prometheus 2.0 (PromCon 2017)
Rule 110 for Prometheus (PromCon 2017)
Counting with Prometheus (CloudNativeCon+Kubecon Europe 2017)
Prometheus: From Berlin to Bonanza (Keynote CloudNativeCon+Kubecon Europe 2017)
What does "monitoring" mean? (FOSDEM 2017)
An Introduction to Prometheus (GrafanaCon 2016)
Provisioning and Capacity Planning (Travel Meets Big Data)
Prometheus - Open Source Forum Japan
Monitoring What Matters: The Prometheus Approach to Whitebox Monitoring (Berl...
So You Want to Write an Exporter
An Exploration of the Formal Properties of PromQL
Life of a Label (PromCon2016, Berlin)
Prometheus (Prometheus London, 2016)

Recently uploaded (20)

PDF
WebRTC in SignalWire - troubleshooting media negotiation
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PPTX
presentation_pfe-universite-molay-seltan.pptx
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
PPTX
Introuction about WHO-FIC in ICD-10.pptx
PPTX
Internet___Basics___Styled_ presentation
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
PPTX
Introuction about ICD -10 and ICD-11 PPT.pptx
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
PPTX
SAP Ariba Sourcing PPT for learning material
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
PDF
Paper PDF World Game (s) Great Redesign.pdf
PPTX
international classification of diseases ICD-10 review PPT.pptx
PDF
Testing WebRTC applications at scale.pdf
PDF
Triggering QUIC, presented by Geoff Huston at IETF 123
WebRTC in SignalWire - troubleshooting media negotiation
An introduction to the IFRS (ISSB) Stndards.pdf
presentation_pfe-universite-molay-seltan.pptx
Job_Card_System_Styled_lorem_ipsum_.pptx
introduction about ICD -10 & ICD-11 ppt.pptx
Introuction about WHO-FIC in ICD-10.pptx
Internet___Basics___Styled_ presentation
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
Introuction about ICD -10 and ICD-11 PPT.pptx
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
Design_with_Watersergyerge45hrbgre4top (1).ppt
SAP Ariba Sourcing PPT for learning material
Tenda Login Guide: Access Your Router in 5 Easy Steps
PptxGenJS_Demo_Chart_20250317130215833.pptx
Slides PDF The World Game (s) Eco Economic Epochs.pdf
The New Creative Director: How AI Tools for Social Media Content Creation Are...
Paper PDF World Game (s) Great Redesign.pdf
international classification of diseases ICD-10 review PPT.pptx
Testing WebRTC applications at scale.pdf
Triggering QUIC, presented by Geoff Huston at IETF 123

No C-QL (Or how I learned to stop worrying, and love eventual consistency) (NoSQL Matters September 2014)

  • 1. No C-QL (Or how I learned to stop worrying, and love eventual consistency) Brian Brazil Senior Software Engineer Boxever
  • 2. Overview NoSQL and eventual consistency are complementary. Why would you need it, how do you take advantage of it, and when is it useful in distributed systems?
  • 3. A Simple Example Website that counts how many times a user visits the site, and each page.
  • 4. First visit User Total Count Brian 1 User Page Count Brian index 1 Webserver DB index Read Old Total Count Insert New Total Count Read Count Insert New Count DB DB
  • 5. Second visit User Total Count Brian 2 User Page Count Brian index 1 Brian sales 1 Webserver sales Read Old Total Count Update New Total Count Read Count Insert New Count DB DB DB
  • 6. What do you think?
  • 7. Initial thoughts Looks like a simple, obvious solution
  • 9. Tabbed Browsing Webserver A: Read Old Total Count B: Read Old Total Count A: Update New Total Count B: Update New Total Count . . . Webserversales index DB DB DB
  • 10. Tabbed Browsing User Total Count Brian 3 User Page Count Brian index 2 Brian sales 2 Webserver A: Read Old Total Count B: Read Old Total Count A: Update New Total Count B: Update New Total Count . . . Webserversales index DB DB DB
  • 11. What happened? Concurrent updates clashed. Need to protect against that.
  • 12. ACID to the rescue! ● Apply each set of updates atomically ● Updates don’t interfere with each other
  • 13. ACID to the rescue? ● Bottleneck for writes ● Webserver needs to retry ● Databases need to coordinate for quorum
  • 14. Aside: Cost of Reads ● Hard disk seek: 5 - 10ms
  • 15. Aside: Cost of Reads ● Hard disk seek: 5 - 10ms ● Cluster quorum read: 1 - 200ms
  • 16. Aside: Cost of Reads ● Hard disk seek: 5 - 10ms ● Cluster quorum read: 1 - 200ms ● RTT to webserver: 1 - 200ms
  • 17. Aside: Cost of Reads ● Hard disk seek: 5 - 10ms ● Cluster quorum read: 1 - 200ms ● RTT to webserver: 1 - 200ms Avoid reads on the write path.
  • 18. Eventual consistency Being slightly out of date doesn’t matter for many applications. Can we take advantage of this to avoid bottlenecks and latency?
  • 19. First visit User UniqueID Page Brian 1409778671-Server1-PID index Webserver DB index Insert Visit DB DB
  • 20. Second visit User UniqueID Page Brian 1409778671-Server1-PID index Brian 1409778689-Server1-PID sales Webserver DB sales Insert Visit DB DB
  • 21. Tabbed Browsing User UniqueID Page Brian 1409778671-Server1-PID index Brian 1409778689-Server1-PID sales Brian 1409778691-Server1-PID index Brian 1409778691-Server2-PID sales DB A: Insert Visit B: Insert Visit DB DB Webserver Webserversales index
  • 22. Analysis ● Unique IDs avoid clashes ● No bottlenecks due to consistency ● Data always internally consistent ● Fire & forget ● Only need to talk to nearest database(s) ● Resilient to network partitions
  • 23. Not all good ● Reads have to look at more data ● Need to make sure data makes it everywhere ● What if something depends on having data up to time X?
  • 24. NoSQL? Everything thus far applies equally to relational and non-relational databases.
  • 25. NoSQL Advantage ● Data locality on disk, multiple entries per row ● Replication options beyond master/slave ● Writes are cheap ● Can also have consistency where needed
  • 26. When is it good? ● Writes dominate ● Need high throughput and scalability ● Inter/intra continental databases ● 100% correct data in realtime not essential
  • 27. When is it not so good? ● Writes are relatively rare ● Scale isn’t a concern ● Data must be completely consistent
  • 28. Idempotency Each entry is unique, so can be safely replayed again and again. Gives you options for disaster recovery: Log requests to local webserver disk, replay if database goes down
  • 29. Improvements ● Take advantage of entry ordering ● Do rollups as a batch task ○ Reduces data to be processed, cutting latency ● Row per day/week/month ○ Avoids rows getting too big ● Handling updates and deletes ○ Can be done using only puts
  • 30. Advanced This is a very simple example, only doing a count. For more see “Extreme availability and self-healing data with CRDTs” at 11am with Uwe Friedrichsen in Room 2
  • 31. Summary Consistency brings bottlenecks. Eventual consistency allows for high- throughput, reliable writes. NoSQL combined with eventual consistency can scale very well.