SlideShare una empresa de Scribd logo
1 de 37
Descargar para leer sin conexión
How Optimizely (Safely)
Maximizes Database
Concurrency
Brian Taylor, Principal Software Engineer at Optimizely
Felipe Mendes, Solution Architect at ScyllaDB
Poll
Where are you in your NoSQL adoption?
How Optimizely (Safely)
Maximizes Database
Concurrency
Brian Taylor, Principal Software Engineer at Optimizely
Felipe Mendes, Solution Architect at ScyllaDB
+ For data-intensive applications that require high
throughput and predictable low latencies
+ Close-to-the-metal design takes full advantage of
modern infrastructure
+ >5x higher throughput
+ >20x lower latency
+ >75% TCO savings
+ Compatible with Apache Cassandra and Amazon
DynamoDB
+ DBaaS/Cloud, Enterprise and Open Source
solutions
The Database for Gamechangers
4
“ScyllaDB stands apart...It’s the rare product
that exceeds my expectations.”
– Martin Heller, InfoWorld contributing editor and reviewer
“For 99.9% of applications, ScyllaDB delivers all the
power a customer will ever need, on workloads that other
databases can’t touch – and at a fraction of the cost of
an in-memory solution.”
– Adrian Bridgewater, Forbes senior contributor
5
+400 Gamechangers Leverage ScyllaDB
Seamless experiences
across content + devices
Digital experiences at
massive scale
Corporate fleet
management
Real-time analytics 2,000,000 SKU -commerce
management
Video recommendation
management
Threat intelligence service
using JanusGraph
Real time fraud detection
across 6M transactions/day
Uber scale, mission critical
chat & messaging app
Network security threat
detection
Power ~50M X1 DVRs with
billions of reqs/day
Precision healthcare via
Edison AI
Inventory hub for retail
operations
Property listings and
updates
Unified ML feature store
across the business
Cryptocurrency exchange
app
Geography-based
recommendations
Global operations- Avon,
Body Shop + more
Predictable performance for
on sale surges
GPS-based exercise
tracking
Serving dynamic live
streams at scale
Powering India's top
social media platform
Personalized
advertising to players
Distribution of game
assets in Unreal Engine
Introductions
Felipe Mendes, Solution Architect at ScyllaDB
+ Years of experience with Linux and other distributed systems
+ An open source enthusiast
+ Passion towards helping businesses to achieve their most challenging
goals
Brian Taylor, Principal Software Engineer at Optimizely
+ I am married with 3 young children
+ I have created 2 programming languages and 2 databases for
legitimate business reasons
+ I love discovering some property in the solution space that, when
maintained, makes everything simpler
Agenda
■ ScyllaDB Loves Concurrency
• To a point
• How to keep the wheels on the
bus
■ Mommy, where does concurrency
come from?
• Easy way
• Good way
ScyllaDB Loves
Concurrency
Conceptual Model
Network Execution
S
R
Q
Q Network Q
Q
Client Client
Why Does Concurrency Matter?
S
R
Rtotal
Reff = Rtotal /4 = (R + 3S) / 4
It lets us hide round trip latency!
Throughput - X - measured in things per second (what you probably care about)
Concurrency - N - number of independent requests happening at the same time (the tool of this talk)
Service Time - S - how long ScyllaDB says a thing took
Request Time - R - how long something takes from the client’s perspective
One at a time
R = S + round trip time
X = 1 / R (pure sequential)
With concurrency
N / R (in the linear region)
X maxX (in the saturation region)
💩 (in the retrograde region)
Definitions
User
User
Classic Closed Loop Load Testing
SUT
User
Request
Response
● Users can have up to one request in flight at any
time
● Users must receive the response to their request
before issuing the next request
● Not directly useful for modern capacity planning
Universal Scaling Law
Generalization of Amdahl’s Law discovered by
Dr. Neil Gunther. As number of users (N)
increases, the system throughput (X) will:
● Enjoy a period of near linear scaling
● Eventually saturate some resource such
that increasing N doesn’t increase X. This
defines maxX
● Possibly encounter a coordination cost
that drives down X with further increasing
N
Saturation
Region
Linear
Region
ScyllaDB-bench, 3x i3.large,
average throughput vs
concurrency
Retrograde
Region
maxX
Modern Open Loop Load Testing
Constant
Throughput
Source
SUT
Does not model users or think times. Instead models load as
a constant throughput load source. Good match for capacity
planning internet connected systems where we typically
know requests per second but don’t really care how many
users are behind that load.
● The start time of every request in the test is
pre-ordained and does not depend on how the SUT is
handling previous requests
● Concurrency is theoretically unbounded
https://github.com/optimizely/scylla-bench-crate
Closed-loop testing: choose concurrency (N)
Open-loop testing: choose throughput (X)
● X in the linear region will imply a bounded N (and R
is very stable)
● X in the saturation region can have unbounded N
and R is very chaotic
● When X exceeds saturation, N and R are undefined
because the system will not keep up
● The USL is not a single valued function of X: This
has interesting implications as X approaches
saturation
Relating the Testing Models
Network Execution
S
R
Q
Q Network Q
Q
4 kops/s
R99 = 1.487 ms
2 <= N <= 22
40 kops/s
R99 = 2.527 ms
23 <= N <= 255
S99 = 0.634 ms
Independent of
kops/s
Linear Region
Linear Region
Throughput is directly proportional to
concurrency
● The size of the cluster (in shards)
and its aggregate SSD throughput
will determine how large the linear
region is
● You should engineering your system
to take full advantage of the linear
region
SSD Throughput
Allocation
4 kops/s
40 kops/s
Saturation Region
Network Execution
S
R
Q
Q Network Q
Q
100 kops/s
R99 = 17.535 ms
295 <= N <= 2540
S99 is increasing
with runtime
Saturation Region
Throughput is approximately constant,
regardless of concurrency
● At this point, assuming a well tuned cluster
and workload, we are writing to disk as fast
as the disks can take it
● Concurrency is no longer a mechanism to
increase throughput and is now becoming
a risk to stability
● You should engineer your system to stay
out of the saturation region
Saturation
Region
Linear
Region
Retrograde
Region
100 kops/s
Network Execution
Q
Q Network Q
Q
Foreground
Background Execution
Q
Compaction Debt
SSD
SSTable Merges
SSTable
Flushes,
Commit Log
Saturation Region
SSD Throughput
Allocation
Retrograde Region
Network Execution
S
R
Q
Q Network Q
Q
100 kops/s
R99 = 55.8 s
75 <= N <= 4096
Once something
bounces us into the
retrograde region,
S99 becomes 1000x
worse than linear
Retrograde Region
Increasing concurrency now decreases
throughput. A system that enters this region is
likely to get stuck here until demand declines
● The harder we push, the less throughput
we get and the more demand builds which
makes us want to push harder
● “Pushing harder” consumes more client
resources (threads, futures, ScyllaDB
driver state). The road to hell will terminate
with an OOM unless there’s some other
limiting factor
Saturation
Region
Linear
Region
Retrograde
Region
100 kops/s
Road to hell
Stay in the linear region and you’ll enjoy consistent latencies and bounded concurrency.
Stray into saturation and you’re likely to get stuck in the retrograde region until load
subsides.
● Scale ScyllaDB such that you’re “always” going to be operating in the linear region
for your expected load
● Design concurrency limiting mechanisms that keep you out of the retrograde region
during unexpected spikes in load
● If you have work to do and can do it in the linear region: DO IT
What Have We Learned?
Where Does Concurrency
Come From?
These are the boring code wonk answers.
● Threads
○ Cheap end: 8kb per go-routine. Low thousands is reasonable
○ Expensive end: 1MB per java thread. Low hundreds is reasonable
● Reactors
○ Rust tokio, java futures, seastar, nodejs callbacks: typically <1kb / instance.
Tens of thousands is reasonable
● Nodes
○ $$ limited
Mechanisms of Concurrency
Data dependency is the mother of sound concurrency
● Easy: No dependency: logging facts at independent keys. Write only
● Medium: Partitionable dependency. As long as we process each independent
streams sequentially, everything will be fine: maintain latest state at a single key
● Hard: Arbitrary “happens-before” relationships: add a relationship between two
nodes in a graph
Mother of Concurrency
● Command: Represents an atomic unit of work. Contains IOPs. Always concludes
with a write, may contain reads.
● IOP: IO Operation. A unit of work for the database.
● Batch: A group of IOPs that may be executed concurrently. Write IOPs within a
batch may literally be combined into a batch operation to ScyllaDB. Batches
execute sequentially with other batches
● Slot: A cubby for data. Has a name. Can be read or written (partition + clustering key
in ScyllaDB)
● Concurrency strategy: How we group IOPs into batches such that the final slot state
is consistent with commands having all been executed sequentially
Definitions
No Dependency
Write A
Command 1 Command 2 Command 4 Command 5
Batch 1
Batch 2
Command 3
Write B Write C
Write D Write E
When commands contain no reads and always write to different slots there can be no data
dependency. The decision about when to switch from batch 1 to 2 can be arbitrary, or driven
by a desire to minimize latency, or to work within the ScyllaDB batch size constraint
For a read/modify/write (RMW) operation to yield correct results, reads must be able to
observe the writes of prior RMWs.
Most streaming platforms (storm, flink, kafka-streams, spark) trivially solve this by
partitioning commands into guaranteed independent streams. This means that:
● Every command has a happens-before relationship with every following command
for the partition key
● Cross command concurrency is impossible within a partition
● Concurrency is limited by the cardinality of the partition key
Read/Modify/Write and “Happens Before”
Command 1
/ Tenant B
Partitioned Concurrency
Read A
Batch 1
Batch 2
Command 2
/ Tenant A
Write B
Read C
The work for each tenant is executed strictly in the order it was received. This guarantees that reads will always
see prior writes but misses opportunities for greater concurrency by being ignorant of non-interacting slot usage
Batch 3
Batch 4 Write B
Read D
Write D
Command 1
/ Tenant A
Happens before Happens before
● Reads of a slot must be able to observe any writes to that slot that came before
them.
○ Writes create a happens-before relationship with any reads that follow them
● The final value in a slot must reflect last write in the sequence
○ Writes create a happens-before relationship with any writes that follow them
Golden Rules of Data Dependency
Command 1
/ Tenant B
Golden Rule Happens Before
Read A
Batch 1
Batch 2
Command 2
/ Tenant A
Write B
Read C
By examining slot usage and applying the golden rules we can eliminate a batch and get
concurrency within a partition
Batch 3 Write B
Read D
Write D
Command 1
/ Tenant A
Happens before
Each of the golden rules implies a simplification rule that we can use to further compress
command execution
● Reads of a slot must be able to observe any writes to that slot that came before
them.
○ Reads do not have to observe prior writes by literally reading the database
● The final value in a slot must reflect last write in the sequence
○ If a prior write is not read from the database, it can be omitted as long as the
final write happens
Simplification Rules of Data Dependency
Command 1
/ Tenant B
Data Dependency Simplification
Read A
Batch 1
Batch 2
Command 2
/ Tenant A
Write B
Read C
Reads can directly read prior writes. Overwritten writes can be skipped.
Write B
Read D
Write D
Command 1
/ Tenant A
Happens before
Data dependency is the mother of sound concurrency. If you can find enough sound
concurrency in your problem then you can exploit the full linear region of ScyllaDB’s
awesome concurrency.
● Case 1: 64 cores, thread and partition concurrency. Maximum throughput about 8
kcommands/s. Very sensitive to “data-shape” aka partition cardinality.
● Case 2: 15 cores, reactor and happens-before concurrency. Maximum throughput
about 30 kcommands/s. Insensitive to most practical “data-shape” issues.
What’s the Point?
Q&A
ScyllaDB University
Free online learning
scylladb.com/university
ScyllaDB Summit
Access 30+ sessions instantly
scylladb.com/summit
ScyllaDB Cloud
Start free Trial
scylladb.com/cloud
@scylladb scylladb/
slack.scylladb.com
@scylladb company/scylladb/
scylladb/
Thank you
for joining us today.
medium.com/engineers-optimizely

Más contenido relacionado

Similar a Optimizely Safely Maximizes Database Concurrency

Database Architecture & Scaling Strategies, in the Cloud & on the Rack
Database Architecture & Scaling Strategies, in the Cloud & on the Rack Database Architecture & Scaling Strategies, in the Cloud & on the Rack
Database Architecture & Scaling Strategies, in the Cloud & on the Rack Clustrix
 
What’s New in ScyllaDB Open Source 5.0
What’s New in ScyllaDB Open Source 5.0What’s New in ScyllaDB Open Source 5.0
What’s New in ScyllaDB Open Source 5.0ScyllaDB
 
Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2aspyker
 
Cassandra for mission critical data
Cassandra for mission critical dataCassandra for mission critical data
Cassandra for mission critical dataOleksandr Semenov
 
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Be...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark  - Demi Be...S3, Cassandra or Outer Space? Dumping Time Series Data using Spark  - Demi Be...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Be...Codemotion
 
C* Summit 2013: Netflix Open Source Tools and Benchmarks for Cassandra by Adr...
C* Summit 2013: Netflix Open Source Tools and Benchmarks for Cassandra by Adr...C* Summit 2013: Netflix Open Source Tools and Benchmarks for Cassandra by Adr...
C* Summit 2013: Netflix Open Source Tools and Benchmarks for Cassandra by Adr...DataStax Academy
 
Tradeoffs in Distributed Systems Design: Is Kafka The Best? (Ben Stopford and...
Tradeoffs in Distributed Systems Design: Is Kafka The Best? (Ben Stopford and...Tradeoffs in Distributed Systems Design: Is Kafka The Best? (Ben Stopford and...
Tradeoffs in Distributed Systems Design: Is Kafka The Best? (Ben Stopford and...HostedbyConfluent
 
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedInJay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedInLinkedIn
 
Our Multi-Year Journey to a 10x Faster Confluent Cloud
Our Multi-Year Journey to a 10x Faster Confluent CloudOur Multi-Year Journey to a 10x Faster Confluent Cloud
Our Multi-Year Journey to a 10x Faster Confluent CloudHostedbyConfluent
 
Scalable complex event processing on samza @UBER
Scalable complex event processing on samza @UBERScalable complex event processing on samza @UBER
Scalable complex event processing on samza @UBERShuyi Chen
 
Cassandra overview
Cassandra overviewCassandra overview
Cassandra overviewSean Murphy
 
Real-world consistency explained
Real-world consistency explainedReal-world consistency explained
Real-world consistency explainedUwe Friedrichsen
 
Lambda architecture @ Indix
Lambda architecture @ IndixLambda architecture @ Indix
Lambda architecture @ IndixRajesh Muppalla
 
Cassandra Summit 2014: Cassandra Compute Cloud: An elastic Cassandra Infrastr...
Cassandra Summit 2014: Cassandra Compute Cloud: An elastic Cassandra Infrastr...Cassandra Summit 2014: Cassandra Compute Cloud: An elastic Cassandra Infrastr...
Cassandra Summit 2014: Cassandra Compute Cloud: An elastic Cassandra Infrastr...DataStax Academy
 
O'Reilly Webinar: Simplicity Scales - Big Data
O'Reilly Webinar: Simplicity Scales - Big Data O'Reilly Webinar: Simplicity Scales - Big Data
O'Reilly Webinar: Simplicity Scales - Big Data Basho Technologies
 

Similar a Optimizely Safely Maximizes Database Concurrency (20)

Database Architecture & Scaling Strategies, in the Cloud & on the Rack
Database Architecture & Scaling Strategies, in the Cloud & on the Rack Database Architecture & Scaling Strategies, in the Cloud & on the Rack
Database Architecture & Scaling Strategies, in the Cloud & on the Rack
 
What’s New in ScyllaDB Open Source 5.0
What’s New in ScyllaDB Open Source 5.0What’s New in ScyllaDB Open Source 5.0
What’s New in ScyllaDB Open Source 5.0
 
Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2
 
Cassandra for mission critical data
Cassandra for mission critical dataCassandra for mission critical data
Cassandra for mission critical data
 
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Be...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark  - Demi Be...S3, Cassandra or Outer Space? Dumping Time Series Data using Spark  - Demi Be...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Be...
 
NoSQL and ACID
NoSQL and ACIDNoSQL and ACID
NoSQL and ACID
 
C* Summit 2013: Netflix Open Source Tools and Benchmarks for Cassandra by Adr...
C* Summit 2013: Netflix Open Source Tools and Benchmarks for Cassandra by Adr...C* Summit 2013: Netflix Open Source Tools and Benchmarks for Cassandra by Adr...
C* Summit 2013: Netflix Open Source Tools and Benchmarks for Cassandra by Adr...
 
Tradeoffs in Distributed Systems Design: Is Kafka The Best? (Ben Stopford and...
Tradeoffs in Distributed Systems Design: Is Kafka The Best? (Ben Stopford and...Tradeoffs in Distributed Systems Design: Is Kafka The Best? (Ben Stopford and...
Tradeoffs in Distributed Systems Design: Is Kafka The Best? (Ben Stopford and...
 
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedInJay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
 
NoSql Database
NoSql DatabaseNoSql Database
NoSql Database
 
Accordion - VLDB 2014
Accordion - VLDB 2014Accordion - VLDB 2014
Accordion - VLDB 2014
 
Our Multi-Year Journey to a 10x Faster Confluent Cloud
Our Multi-Year Journey to a 10x Faster Confluent CloudOur Multi-Year Journey to a 10x Faster Confluent Cloud
Our Multi-Year Journey to a 10x Faster Confluent Cloud
 
Scalable complex event processing on samza @UBER
Scalable complex event processing on samza @UBERScalable complex event processing on samza @UBER
Scalable complex event processing on samza @UBER
 
NoSQL Evolution
NoSQL EvolutionNoSQL Evolution
NoSQL Evolution
 
Cassandra overview
Cassandra overviewCassandra overview
Cassandra overview
 
Real-world consistency explained
Real-world consistency explainedReal-world consistency explained
Real-world consistency explained
 
Lambda architecture @ Indix
Lambda architecture @ IndixLambda architecture @ Indix
Lambda architecture @ Indix
 
Cassandra Summit 2014: Cassandra Compute Cloud: An elastic Cassandra Infrastr...
Cassandra Summit 2014: Cassandra Compute Cloud: An elastic Cassandra Infrastr...Cassandra Summit 2014: Cassandra Compute Cloud: An elastic Cassandra Infrastr...
Cassandra Summit 2014: Cassandra Compute Cloud: An elastic Cassandra Infrastr...
 
O'Reilly Webinar: Simplicity Scales - Big Data
O'Reilly Webinar: Simplicity Scales - Big Data O'Reilly Webinar: Simplicity Scales - Big Data
O'Reilly Webinar: Simplicity Scales - Big Data
 
Cassandra
CassandraCassandra
Cassandra
 

Más de ScyllaDB

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
What Developers Need to Unlearn for High Performance NoSQL
What Developers Need to Unlearn for High Performance NoSQLWhat Developers Need to Unlearn for High Performance NoSQL
What Developers Need to Unlearn for High Performance NoSQLScyllaDB
 
Low Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & PitfallsLow Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & PitfallsScyllaDB
 
Dissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasDissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasScyllaDB
 
Beyond Linear Scaling: A New Path for Performance with ScyllaDB
Beyond Linear Scaling: A New Path for Performance with ScyllaDBBeyond Linear Scaling: A New Path for Performance with ScyllaDB
Beyond Linear Scaling: A New Path for Performance with ScyllaDBScyllaDB
 
Dissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasDissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasScyllaDB
 
Database Performance at Scale Masterclass: Workload Characteristics by Felipe...
Database Performance at Scale Masterclass: Workload Characteristics by Felipe...Database Performance at Scale Masterclass: Workload Characteristics by Felipe...
Database Performance at Scale Masterclass: Workload Characteristics by Felipe...ScyllaDB
 
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...ScyllaDB
 
Database Performance at Scale Masterclass: Driver Strategies by Piotr Sarna
Database Performance at Scale Masterclass: Driver Strategies by Piotr SarnaDatabase Performance at Scale Masterclass: Driver Strategies by Piotr Sarna
Database Performance at Scale Masterclass: Driver Strategies by Piotr SarnaScyllaDB
 
Replacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDBReplacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDBScyllaDB
 
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear Scalability
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear ScalabilityPowering Real-Time Apps with ScyllaDB_ Low Latency & Linear Scalability
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear ScalabilityScyllaDB
 
7 Reasons Not to Put an External Cache in Front of Your Database.pptx
7 Reasons Not to Put an External Cache in Front of Your Database.pptx7 Reasons Not to Put an External Cache in Front of Your Database.pptx
7 Reasons Not to Put an External Cache in Front of Your Database.pptxScyllaDB
 
Getting the most out of ScyllaDB
Getting the most out of ScyllaDBGetting the most out of ScyllaDB
Getting the most out of ScyllaDBScyllaDB
 
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a Migration
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a MigrationNoSQL Database Migration Masterclass - Session 2: The Anatomy of a Migration
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a MigrationScyllaDB
 
NoSQL Database Migration Masterclass - Session 3: Migration Logistics
NoSQL Database Migration Masterclass - Session 3: Migration LogisticsNoSQL Database Migration Masterclass - Session 3: Migration Logistics
NoSQL Database Migration Masterclass - Session 3: Migration LogisticsScyllaDB
 
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and Challenges
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and ChallengesNoSQL Data Migration Masterclass - Session 1 Migration Strategies and Challenges
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and ChallengesScyllaDB
 
ScyllaDB Virtual Workshop
ScyllaDB Virtual WorkshopScyllaDB Virtual Workshop
ScyllaDB Virtual WorkshopScyllaDB
 
DBaaS in the Real World: Risks, Rewards & Tradeoffs
DBaaS in the Real World: Risks, Rewards & TradeoffsDBaaS in the Real World: Risks, Rewards & Tradeoffs
DBaaS in the Real World: Risks, Rewards & TradeoffsScyllaDB
 
Build Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBBuild Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBScyllaDB
 
NoSQL Data Modeling 101
NoSQL Data Modeling 101NoSQL Data Modeling 101
NoSQL Data Modeling 101ScyllaDB
 

Más de ScyllaDB (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
What Developers Need to Unlearn for High Performance NoSQL
What Developers Need to Unlearn for High Performance NoSQLWhat Developers Need to Unlearn for High Performance NoSQL
What Developers Need to Unlearn for High Performance NoSQL
 
Low Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & PitfallsLow Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & Pitfalls
 
Dissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasDissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance Dilemmas
 
Beyond Linear Scaling: A New Path for Performance with ScyllaDB
Beyond Linear Scaling: A New Path for Performance with ScyllaDBBeyond Linear Scaling: A New Path for Performance with ScyllaDB
Beyond Linear Scaling: A New Path for Performance with ScyllaDB
 
Dissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasDissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance Dilemmas
 
Database Performance at Scale Masterclass: Workload Characteristics by Felipe...
Database Performance at Scale Masterclass: Workload Characteristics by Felipe...Database Performance at Scale Masterclass: Workload Characteristics by Felipe...
Database Performance at Scale Masterclass: Workload Characteristics by Felipe...
 
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...
 
Database Performance at Scale Masterclass: Driver Strategies by Piotr Sarna
Database Performance at Scale Masterclass: Driver Strategies by Piotr SarnaDatabase Performance at Scale Masterclass: Driver Strategies by Piotr Sarna
Database Performance at Scale Masterclass: Driver Strategies by Piotr Sarna
 
Replacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDBReplacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDB
 
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear Scalability
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear ScalabilityPowering Real-Time Apps with ScyllaDB_ Low Latency & Linear Scalability
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear Scalability
 
7 Reasons Not to Put an External Cache in Front of Your Database.pptx
7 Reasons Not to Put an External Cache in Front of Your Database.pptx7 Reasons Not to Put an External Cache in Front of Your Database.pptx
7 Reasons Not to Put an External Cache in Front of Your Database.pptx
 
Getting the most out of ScyllaDB
Getting the most out of ScyllaDBGetting the most out of ScyllaDB
Getting the most out of ScyllaDB
 
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a Migration
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a MigrationNoSQL Database Migration Masterclass - Session 2: The Anatomy of a Migration
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a Migration
 
NoSQL Database Migration Masterclass - Session 3: Migration Logistics
NoSQL Database Migration Masterclass - Session 3: Migration LogisticsNoSQL Database Migration Masterclass - Session 3: Migration Logistics
NoSQL Database Migration Masterclass - Session 3: Migration Logistics
 
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and Challenges
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and ChallengesNoSQL Data Migration Masterclass - Session 1 Migration Strategies and Challenges
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and Challenges
 
ScyllaDB Virtual Workshop
ScyllaDB Virtual WorkshopScyllaDB Virtual Workshop
ScyllaDB Virtual Workshop
 
DBaaS in the Real World: Risks, Rewards & Tradeoffs
DBaaS in the Real World: Risks, Rewards & TradeoffsDBaaS in the Real World: Risks, Rewards & Tradeoffs
DBaaS in the Real World: Risks, Rewards & Tradeoffs
 
Build Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBBuild Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDB
 
NoSQL Data Modeling 101
NoSQL Data Modeling 101NoSQL Data Modeling 101
NoSQL Data Modeling 101
 

Último

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 

Optimizely Safely Maximizes Database Concurrency

  • 1. How Optimizely (Safely) Maximizes Database Concurrency Brian Taylor, Principal Software Engineer at Optimizely Felipe Mendes, Solution Architect at ScyllaDB
  • 2. Poll Where are you in your NoSQL adoption?
  • 3. How Optimizely (Safely) Maximizes Database Concurrency Brian Taylor, Principal Software Engineer at Optimizely Felipe Mendes, Solution Architect at ScyllaDB
  • 4. + For data-intensive applications that require high throughput and predictable low latencies + Close-to-the-metal design takes full advantage of modern infrastructure + >5x higher throughput + >20x lower latency + >75% TCO savings + Compatible with Apache Cassandra and Amazon DynamoDB + DBaaS/Cloud, Enterprise and Open Source solutions The Database for Gamechangers 4 “ScyllaDB stands apart...It’s the rare product that exceeds my expectations.” – Martin Heller, InfoWorld contributing editor and reviewer “For 99.9% of applications, ScyllaDB delivers all the power a customer will ever need, on workloads that other databases can’t touch – and at a fraction of the cost of an in-memory solution.” – Adrian Bridgewater, Forbes senior contributor
  • 5. 5 +400 Gamechangers Leverage ScyllaDB Seamless experiences across content + devices Digital experiences at massive scale Corporate fleet management Real-time analytics 2,000,000 SKU -commerce management Video recommendation management Threat intelligence service using JanusGraph Real time fraud detection across 6M transactions/day Uber scale, mission critical chat & messaging app Network security threat detection Power ~50M X1 DVRs with billions of reqs/day Precision healthcare via Edison AI Inventory hub for retail operations Property listings and updates Unified ML feature store across the business Cryptocurrency exchange app Geography-based recommendations Global operations- Avon, Body Shop + more Predictable performance for on sale surges GPS-based exercise tracking Serving dynamic live streams at scale Powering India's top social media platform Personalized advertising to players Distribution of game assets in Unreal Engine
  • 6. Introductions Felipe Mendes, Solution Architect at ScyllaDB + Years of experience with Linux and other distributed systems + An open source enthusiast + Passion towards helping businesses to achieve their most challenging goals Brian Taylor, Principal Software Engineer at Optimizely + I am married with 3 young children + I have created 2 programming languages and 2 databases for legitimate business reasons + I love discovering some property in the solution space that, when maintained, makes everything simpler
  • 7. Agenda ■ ScyllaDB Loves Concurrency • To a point • How to keep the wheels on the bus ■ Mommy, where does concurrency come from? • Easy way • Good way
  • 9. Conceptual Model Network Execution S R Q Q Network Q Q Client Client
  • 10. Why Does Concurrency Matter? S R Rtotal Reff = Rtotal /4 = (R + 3S) / 4 It lets us hide round trip latency!
  • 11. Throughput - X - measured in things per second (what you probably care about) Concurrency - N - number of independent requests happening at the same time (the tool of this talk) Service Time - S - how long ScyllaDB says a thing took Request Time - R - how long something takes from the client’s perspective One at a time R = S + round trip time X = 1 / R (pure sequential) With concurrency N / R (in the linear region) X maxX (in the saturation region) 💩 (in the retrograde region) Definitions
  • 12. User User Classic Closed Loop Load Testing SUT User Request Response ● Users can have up to one request in flight at any time ● Users must receive the response to their request before issuing the next request ● Not directly useful for modern capacity planning
  • 13. Universal Scaling Law Generalization of Amdahl’s Law discovered by Dr. Neil Gunther. As number of users (N) increases, the system throughput (X) will: ● Enjoy a period of near linear scaling ● Eventually saturate some resource such that increasing N doesn’t increase X. This defines maxX ● Possibly encounter a coordination cost that drives down X with further increasing N Saturation Region Linear Region ScyllaDB-bench, 3x i3.large, average throughput vs concurrency Retrograde Region maxX
  • 14. Modern Open Loop Load Testing Constant Throughput Source SUT Does not model users or think times. Instead models load as a constant throughput load source. Good match for capacity planning internet connected systems where we typically know requests per second but don’t really care how many users are behind that load. ● The start time of every request in the test is pre-ordained and does not depend on how the SUT is handling previous requests ● Concurrency is theoretically unbounded https://github.com/optimizely/scylla-bench-crate
  • 15. Closed-loop testing: choose concurrency (N) Open-loop testing: choose throughput (X) ● X in the linear region will imply a bounded N (and R is very stable) ● X in the saturation region can have unbounded N and R is very chaotic ● When X exceeds saturation, N and R are undefined because the system will not keep up ● The USL is not a single valued function of X: This has interesting implications as X approaches saturation Relating the Testing Models
  • 16. Network Execution S R Q Q Network Q Q 4 kops/s R99 = 1.487 ms 2 <= N <= 22 40 kops/s R99 = 2.527 ms 23 <= N <= 255 S99 = 0.634 ms Independent of kops/s Linear Region
  • 17. Linear Region Throughput is directly proportional to concurrency ● The size of the cluster (in shards) and its aggregate SSD throughput will determine how large the linear region is ● You should engineering your system to take full advantage of the linear region SSD Throughput Allocation 4 kops/s 40 kops/s
  • 18. Saturation Region Network Execution S R Q Q Network Q Q 100 kops/s R99 = 17.535 ms 295 <= N <= 2540 S99 is increasing with runtime
  • 19. Saturation Region Throughput is approximately constant, regardless of concurrency ● At this point, assuming a well tuned cluster and workload, we are writing to disk as fast as the disks can take it ● Concurrency is no longer a mechanism to increase throughput and is now becoming a risk to stability ● You should engineer your system to stay out of the saturation region Saturation Region Linear Region Retrograde Region 100 kops/s
  • 20. Network Execution Q Q Network Q Q Foreground Background Execution Q Compaction Debt SSD SSTable Merges SSTable Flushes, Commit Log Saturation Region SSD Throughput Allocation
  • 21. Retrograde Region Network Execution S R Q Q Network Q Q 100 kops/s R99 = 55.8 s 75 <= N <= 4096 Once something bounces us into the retrograde region, S99 becomes 1000x worse than linear
  • 22. Retrograde Region Increasing concurrency now decreases throughput. A system that enters this region is likely to get stuck here until demand declines ● The harder we push, the less throughput we get and the more demand builds which makes us want to push harder ● “Pushing harder” consumes more client resources (threads, futures, ScyllaDB driver state). The road to hell will terminate with an OOM unless there’s some other limiting factor Saturation Region Linear Region Retrograde Region 100 kops/s Road to hell
  • 23. Stay in the linear region and you’ll enjoy consistent latencies and bounded concurrency. Stray into saturation and you’re likely to get stuck in the retrograde region until load subsides. ● Scale ScyllaDB such that you’re “always” going to be operating in the linear region for your expected load ● Design concurrency limiting mechanisms that keep you out of the retrograde region during unexpected spikes in load ● If you have work to do and can do it in the linear region: DO IT What Have We Learned?
  • 25. These are the boring code wonk answers. ● Threads ○ Cheap end: 8kb per go-routine. Low thousands is reasonable ○ Expensive end: 1MB per java thread. Low hundreds is reasonable ● Reactors ○ Rust tokio, java futures, seastar, nodejs callbacks: typically <1kb / instance. Tens of thousands is reasonable ● Nodes ○ $$ limited Mechanisms of Concurrency
  • 26. Data dependency is the mother of sound concurrency ● Easy: No dependency: logging facts at independent keys. Write only ● Medium: Partitionable dependency. As long as we process each independent streams sequentially, everything will be fine: maintain latest state at a single key ● Hard: Arbitrary “happens-before” relationships: add a relationship between two nodes in a graph Mother of Concurrency
  • 27. ● Command: Represents an atomic unit of work. Contains IOPs. Always concludes with a write, may contain reads. ● IOP: IO Operation. A unit of work for the database. ● Batch: A group of IOPs that may be executed concurrently. Write IOPs within a batch may literally be combined into a batch operation to ScyllaDB. Batches execute sequentially with other batches ● Slot: A cubby for data. Has a name. Can be read or written (partition + clustering key in ScyllaDB) ● Concurrency strategy: How we group IOPs into batches such that the final slot state is consistent with commands having all been executed sequentially Definitions
  • 28. No Dependency Write A Command 1 Command 2 Command 4 Command 5 Batch 1 Batch 2 Command 3 Write B Write C Write D Write E When commands contain no reads and always write to different slots there can be no data dependency. The decision about when to switch from batch 1 to 2 can be arbitrary, or driven by a desire to minimize latency, or to work within the ScyllaDB batch size constraint
  • 29. For a read/modify/write (RMW) operation to yield correct results, reads must be able to observe the writes of prior RMWs. Most streaming platforms (storm, flink, kafka-streams, spark) trivially solve this by partitioning commands into guaranteed independent streams. This means that: ● Every command has a happens-before relationship with every following command for the partition key ● Cross command concurrency is impossible within a partition ● Concurrency is limited by the cardinality of the partition key Read/Modify/Write and “Happens Before”
  • 30. Command 1 / Tenant B Partitioned Concurrency Read A Batch 1 Batch 2 Command 2 / Tenant A Write B Read C The work for each tenant is executed strictly in the order it was received. This guarantees that reads will always see prior writes but misses opportunities for greater concurrency by being ignorant of non-interacting slot usage Batch 3 Batch 4 Write B Read D Write D Command 1 / Tenant A Happens before Happens before
  • 31. ● Reads of a slot must be able to observe any writes to that slot that came before them. ○ Writes create a happens-before relationship with any reads that follow them ● The final value in a slot must reflect last write in the sequence ○ Writes create a happens-before relationship with any writes that follow them Golden Rules of Data Dependency
  • 32. Command 1 / Tenant B Golden Rule Happens Before Read A Batch 1 Batch 2 Command 2 / Tenant A Write B Read C By examining slot usage and applying the golden rules we can eliminate a batch and get concurrency within a partition Batch 3 Write B Read D Write D Command 1 / Tenant A Happens before
  • 33. Each of the golden rules implies a simplification rule that we can use to further compress command execution ● Reads of a slot must be able to observe any writes to that slot that came before them. ○ Reads do not have to observe prior writes by literally reading the database ● The final value in a slot must reflect last write in the sequence ○ If a prior write is not read from the database, it can be omitted as long as the final write happens Simplification Rules of Data Dependency
  • 34. Command 1 / Tenant B Data Dependency Simplification Read A Batch 1 Batch 2 Command 2 / Tenant A Write B Read C Reads can directly read prior writes. Overwritten writes can be skipped. Write B Read D Write D Command 1 / Tenant A Happens before
  • 35. Data dependency is the mother of sound concurrency. If you can find enough sound concurrency in your problem then you can exploit the full linear region of ScyllaDB’s awesome concurrency. ● Case 1: 64 cores, thread and partition concurrency. Maximum throughput about 8 kcommands/s. Very sensitive to “data-shape” aka partition cardinality. ● Case 2: 15 cores, reactor and happens-before concurrency. Maximum throughput about 30 kcommands/s. Insensitive to most practical “data-shape” issues. What’s the Point?
  • 36. Q&A ScyllaDB University Free online learning scylladb.com/university ScyllaDB Summit Access 30+ sessions instantly scylladb.com/summit ScyllaDB Cloud Start free Trial scylladb.com/cloud
  • 37. @scylladb scylladb/ slack.scylladb.com @scylladb company/scylladb/ scylladb/ Thank you for joining us today. medium.com/engineers-optimizely