Database Performance at Scale Masterclass: Driver Strategies by Piotr Sarna

ScyllaDB
ScyllaDBScyllaDB
Drivers
Piotr Sarna
piotr@sarna.dev sarna@turso.tech
Piotr Sarna
● Wrote a few patches for the Linux kernel
● Ex-maintainer of ScyllaDB and Seastar
● Staff @Turso
● Maintainer of libSQL
Drivers
3
Communication tools for database users
● binary protocols
● HTTP
● gRPC
Clients vs Servers
4
Clients vs Servers
Clients:
● want stuff done as fast as possible
● don’t usually care much about other clients
Servers:
● want to have things to do all the time
● but not too many things
● cooperate with other fellow servers
5
Workload types
a.k.a. types of annoying clients
6
interactive:
“webpage users”
batch:
“Spark job”
Throughput vs Goodput
Throughput:
measure of how much data you can squeeze through
Goodput:
measure of much useful data you can squeeze through
7
Throughput vs Goodput
Throughput:
1MiB of data, retried 10 times, 10MiB worth of error logs => 20 MiB/s!
Goodput:
1MiB of data, retried 10 times, 10MiB worth of error logs => 1 MiB/s
8
(nobody cares)
Timeouts
User-side timeouts: “whew, they finally gave up trying”
Server-side timeouts: “I’m tired, boss”
9
User-side timeouts
Tricky.
A server doesn’t necessarily know the user gave up.
May trigger a retry, which just makes the load worse.
Drivers can’t assume the servers know.
10
Server-side timeouts
Not tricky.
A nice backpressure mechanism.
Server should clearly inform why the request was refused.
11
Context
12
Topology
Some databases expose their topology, some don’t.
For those who do, drivers should track topology changes.
13
Topology
Ways of learning topology
● polling servers for topology information
● subscribing to topology change events
● taking part in the topology change process
○ gossiping
○ consensus algorithms
14
Metadata
15
● load statistics
○ current load
○ historical load
● priority
○ prefer servers with faster disks
○ prefer servers with more memory
● physical distance
Caching
16
Caching
■ prepared statements
■ query results
■ topology
17
Caching prepared statements
Example algorithms:
■ LRU
○ with multiple pools to avoid thrashing
■ LFU
Do not prepare oneshot statements.
18
Caching query results
Local cache -> relaxed consistency guarantees
Usually better to be done in the app, not in the driver
19
Caching topology & schema
Clients cannot assume they are up-to-date with topology or schema.
On failed assumption:
● client tries to contact a dead node
● client contacts a node that doesn’t have certain data anymore
● client contacts a node that is not yet up-to-date with all data
Server reaction:
● refuse to execute, ask to refresh topology and/or schema
● refuse to execute, reroute to the right node
● refuse to execute, send updated topology/schema info
● act as proxy
20
Retries
21
Retries
a.k.a. clients being even more annoying than usual
To retry, or not to retry?
● timeouts
○ read timeouts
○ write timeouts
● temporary errors
○ overload
○ dead node
○ schema mismatch
● permanent errors
○ bad syntax
○ authentication error
○ authorization error
22
Idempotence
Can a query be safely executed multiple times?
23
Query OK to retry?
SELECT * FROM t; yep
CREATE TABLE IF NOT EXISTS t(v int PRIMARY KEY); sure
INSERT INTO T(v) VALUES (42) USING TIMESTAMP 123; ok*
UPDATE t SET v = v + 42; nnnope*
Retry policies
● do not retry
● retry on the same server
● retry on another server
● retry after some delay
● retry speculatively
24
Paging
25
Paging
26
Serving results in smaller bits.
● protects server memory
● protects clients' memory
● improves overall latency
● can be hidden behind driver API: e.g. result streams
● users can tweak parameters: page size
Concurrency
27
Concurrency
Doing multiple things at a time.
High == good, but to a degree.
Modern hardware loves concurrency.
28
Keep in touch!
Piotr Sarna
Staff @Turso
piotr@sarna.dev
sarna@turso.tech
@sarna_dev
1 of 29

Recommended

Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La... by
Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...
Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...InfluxData
348 views35 slides
#OSSPARIS19 - How to improve database observability - CHARLES JUDITH, Criteo by
#OSSPARIS19 - How to improve database observability - CHARLES JUDITH, Criteo#OSSPARIS19 - How to improve database observability - CHARLES JUDITH, Criteo
#OSSPARIS19 - How to improve database observability - CHARLES JUDITH, CriteoParis Open Source Summit
30 views43 slides
Flink Forward San Francisco 2018: Gregory Fee - "Bootstrapping State In Apach... by
Flink Forward San Francisco 2018: Gregory Fee - "Bootstrapping State In Apach...Flink Forward San Francisco 2018: Gregory Fee - "Bootstrapping State In Apach...
Flink Forward San Francisco 2018: Gregory Fee - "Bootstrapping State In Apach...Flink Forward
1.6K views30 slides
MySQL X protocol - Talking to MySQL Directly over the Wire by
MySQL X protocol - Talking to MySQL Directly over the WireMySQL X protocol - Talking to MySQL Directly over the Wire
MySQL X protocol - Talking to MySQL Directly over the WireSimon J Mudd
3.3K views60 slides
PyCon Poland 2016: Maintaining a high load Python project: typical mistakes by
PyCon Poland 2016: Maintaining a high load Python project: typical mistakesPyCon Poland 2016: Maintaining a high load Python project: typical mistakes
PyCon Poland 2016: Maintaining a high load Python project: typical mistakesViach Kakovskyi
2.5K views53 slides
University of Delaware - Improving Web Protocols (early SPDY talk) by
University of Delaware - Improving Web Protocols (early SPDY talk)University of Delaware - Improving Web Protocols (early SPDY talk)
University of Delaware - Improving Web Protocols (early SPDY talk)Mike Belshe
920 views37 slides

More Related Content

Similar to Database Performance at Scale Masterclass: Driver Strategies by Piotr Sarna

Bootstrapping state in Apache Flink by
Bootstrapping state in Apache FlinkBootstrapping state in Apache Flink
Bootstrapping state in Apache FlinkDataWorks Summit
1.7K views30 slides
On component interface by
On component interfaceOn component interface
On component interfaceLaurence Chen
182 views40 slides
MongoDB World 2019: Packing Up Your Data and Moving to MongoDB Atlas by
MongoDB World 2019: Packing Up Your Data and Moving to MongoDB AtlasMongoDB World 2019: Packing Up Your Data and Moving to MongoDB Atlas
MongoDB World 2019: Packing Up Your Data and Moving to MongoDB AtlasMongoDB
391 views38 slides
Learnings from the Field. Lessons from Working with Dozens of Small & Large D... by
Learnings from the Field. Lessons from Working with Dozens of Small & Large D...Learnings from the Field. Lessons from Working with Dozens of Small & Large D...
Learnings from the Field. Lessons from Working with Dozens of Small & Large D...HostedbyConfluent
811 views29 slides
Strata+Hadoop 2017 San Jose: Lessons from a year of supporting Apache Kafka by
Strata+Hadoop 2017 San Jose: Lessons from a year of supporting Apache KafkaStrata+Hadoop 2017 San Jose: Lessons from a year of supporting Apache Kafka
Strata+Hadoop 2017 San Jose: Lessons from a year of supporting Apache Kafkaconfluent
854 views23 slides
Accumulo Summit Keynote 2018 by
Accumulo Summit Keynote 2018Accumulo Summit Keynote 2018
Accumulo Summit Keynote 2018Accumulo Summit
114 views48 slides

Similar to Database Performance at Scale Masterclass: Driver Strategies by Piotr Sarna(20)

Bootstrapping state in Apache Flink by DataWorks Summit
Bootstrapping state in Apache FlinkBootstrapping state in Apache Flink
Bootstrapping state in Apache Flink
DataWorks Summit1.7K views
MongoDB World 2019: Packing Up Your Data and Moving to MongoDB Atlas by MongoDB
MongoDB World 2019: Packing Up Your Data and Moving to MongoDB AtlasMongoDB World 2019: Packing Up Your Data and Moving to MongoDB Atlas
MongoDB World 2019: Packing Up Your Data and Moving to MongoDB Atlas
MongoDB391 views
Learnings from the Field. Lessons from Working with Dozens of Small & Large D... by HostedbyConfluent
Learnings from the Field. Lessons from Working with Dozens of Small & Large D...Learnings from the Field. Lessons from Working with Dozens of Small & Large D...
Learnings from the Field. Lessons from Working with Dozens of Small & Large D...
HostedbyConfluent811 views
Strata+Hadoop 2017 San Jose: Lessons from a year of supporting Apache Kafka by confluent
Strata+Hadoop 2017 San Jose: Lessons from a year of supporting Apache KafkaStrata+Hadoop 2017 San Jose: Lessons from a year of supporting Apache Kafka
Strata+Hadoop 2017 San Jose: Lessons from a year of supporting Apache Kafka
confluent854 views
OSMC 2019 | How to improve database Observability by Charles Judith by NETWAYS
OSMC 2019 | How to improve database Observability by Charles JudithOSMC 2019 | How to improve database Observability by Charles Judith
OSMC 2019 | How to improve database Observability by Charles Judith
NETWAYS108 views
Microservices summit talk 1/31 by Varun Talwar
Microservices summit talk   1/31Microservices summit talk   1/31
Microservices summit talk 1/31
Varun Talwar760 views
Bringing Learnings from Googley Microservices with gRPC - Varun Talwar, Google by Ambassador Labs
Bringing Learnings from Googley Microservices with gRPC - Varun Talwar, GoogleBringing Learnings from Googley Microservices with gRPC - Varun Talwar, Google
Bringing Learnings from Googley Microservices with gRPC - Varun Talwar, Google
Ambassador Labs6.3K views
Temporal Performance Modelling of Serverless Computing Platforms - WoSC6 by Nima Mahmoudi
Temporal Performance Modelling of Serverless Computing Platforms - WoSC6Temporal Performance Modelling of Serverless Computing Platforms - WoSC6
Temporal Performance Modelling of Serverless Computing Platforms - WoSC6
Nima Mahmoudi71 views
Performance Modeling of Serverless Computing Platforms - CASCON2020 Workshop ... by Nima Mahmoudi
Performance Modeling of Serverless Computing Platforms - CASCON2020 Workshop ...Performance Modeling of Serverless Computing Platforms - CASCON2020 Workshop ...
Performance Modeling of Serverless Computing Platforms - CASCON2020 Workshop ...
Nima Mahmoudi205 views
Build real time stream processing applications using Apache Kafka by Hotstar
Build real time stream processing applications using Apache KafkaBuild real time stream processing applications using Apache Kafka
Build real time stream processing applications using Apache Kafka
Hotstar615 views
The Dark Side Of Go -- Go runtime related problems in TiDB in production by PingCAP
The Dark Side Of Go -- Go runtime related problems in TiDB  in productionThe Dark Side Of Go -- Go runtime related problems in TiDB  in production
The Dark Side Of Go -- Go runtime related problems in TiDB in production
PingCAP444 views
Series of Unfortunate Netflix Container Events - QConNYC17 by aspyker
Series of Unfortunate Netflix Container Events - QConNYC17Series of Unfortunate Netflix Container Events - QConNYC17
Series of Unfortunate Netflix Container Events - QConNYC17
aspyker3.8K views
No C-QL (Or how I learned to stop worrying, and love eventual consistency) (N... by Brian Brazil
No C-QL (Or how I learned to stop worrying, and love eventual consistency) (N...No C-QL (Or how I learned to stop worrying, and love eventual consistency) (N...
No C-QL (Or how I learned to stop worrying, and love eventual consistency) (N...
Brian Brazil527 views
Евгений Хыст "Application performance database related problems" by Anna Shymchenko
Евгений Хыст "Application performance database related problems"Евгений Хыст "Application performance database related problems"
Евгений Хыст "Application performance database related problems"
Anna Shymchenko328 views
Web performance mercadolibre - ECI 2013 by Santiago Aimetta
Web performance   mercadolibre - ECI 2013Web performance   mercadolibre - ECI 2013
Web performance mercadolibre - ECI 2013
Santiago Aimetta1.2K views

More from ScyllaDB

Database Performance at Scale Masterclass: Workload Characteristics by Felipe... by
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
125 views28 slides
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya... by
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
101 views22 slides
Replacing Your Cache with ScyllaDB by
Replacing Your Cache with ScyllaDBReplacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDBScyllaDB
316 views63 slides
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear Scalability by
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
141 views24 slides
7 Reasons Not to Put an External Cache in Front of Your Database.pptx by
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
110 views68 slides
Getting the most out of ScyllaDB by
Getting the most out of ScyllaDBGetting the most out of ScyllaDB
Getting the most out of ScyllaDBScyllaDB
179 views17 slides

More from ScyllaDB(20)

Database Performance at Scale Masterclass: Workload Characteristics by Felipe... by ScyllaDB
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...
ScyllaDB125 views
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya... by 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...
ScyllaDB101 views
Replacing Your Cache with ScyllaDB by ScyllaDB
Replacing Your Cache with ScyllaDBReplacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDB
ScyllaDB316 views
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear Scalability by ScyllaDB
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
ScyllaDB141 views
7 Reasons Not to Put an External Cache in Front of Your Database.pptx by ScyllaDB
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
ScyllaDB110 views
Getting the most out of ScyllaDB by ScyllaDB
Getting the most out of ScyllaDBGetting the most out of ScyllaDB
Getting the most out of ScyllaDB
ScyllaDB179 views
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a Migration by ScyllaDB
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
ScyllaDB55 views
NoSQL Database Migration Masterclass - Session 3: Migration Logistics by ScyllaDB
NoSQL Database Migration Masterclass - Session 3: Migration LogisticsNoSQL Database Migration Masterclass - Session 3: Migration Logistics
NoSQL Database Migration Masterclass - Session 3: Migration Logistics
ScyllaDB59 views
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and Challenges by ScyllaDB
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
ScyllaDB86 views
ScyllaDB Virtual Workshop by ScyllaDB
ScyllaDB Virtual WorkshopScyllaDB Virtual Workshop
ScyllaDB Virtual Workshop
ScyllaDB198 views
DBaaS in the Real World: Risks, Rewards & Tradeoffs by ScyllaDB
DBaaS in the Real World: Risks, Rewards & TradeoffsDBaaS in the Real World: Risks, Rewards & Tradeoffs
DBaaS in the Real World: Risks, Rewards & Tradeoffs
ScyllaDB165 views
Build Low-Latency Applications in Rust on ScyllaDB by ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBBuild Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDB
ScyllaDB650 views
NoSQL Data Modeling 101 by ScyllaDB
NoSQL Data Modeling 101NoSQL Data Modeling 101
NoSQL Data Modeling 101
ScyllaDB80 views
Top NoSQL Data Modeling Mistakes by ScyllaDB
Top NoSQL Data Modeling MistakesTop NoSQL Data Modeling Mistakes
Top NoSQL Data Modeling Mistakes
ScyllaDB107 views
NoSQL Data Modeling Foundations — Introducing Concepts & Principles by ScyllaDB
NoSQL Data Modeling Foundations — Introducing Concepts & PrinciplesNoSQL Data Modeling Foundations — Introducing Concepts & Principles
NoSQL Data Modeling Foundations — Introducing Concepts & Principles
ScyllaDB188 views
Optimizing Performance in Rust for Low-Latency Database Drivers by ScyllaDB
Optimizing Performance in Rust for Low-Latency Database DriversOptimizing Performance in Rust for Low-Latency Database Drivers
Optimizing Performance in Rust for Low-Latency Database Drivers
ScyllaDB254 views
Overcoming Media Streaming Challenges with NoSQL by ScyllaDB
Overcoming Media Streaming Challenges with NoSQLOvercoming Media Streaming Challenges with NoSQL
Overcoming Media Streaming Challenges with NoSQL
ScyllaDB247 views
How Optimizely (Safely) Maximizes Database Concurrency.pdf by ScyllaDB
How Optimizely (Safely) Maximizes Database Concurrency.pdfHow Optimizely (Safely) Maximizes Database Concurrency.pdf
How Optimizely (Safely) Maximizes Database Concurrency.pdf
ScyllaDB338 views
How Development Teams Cut Costs with ScyllaDB.pdf by ScyllaDB
How Development Teams Cut Costs with ScyllaDB.pdfHow Development Teams Cut Costs with ScyllaDB.pdf
How Development Teams Cut Costs with ScyllaDB.pdf
ScyllaDB292 views
Learning Rust the Hard Way for a Production Kafka + ScyllaDB Pipeline by ScyllaDB
Learning Rust the Hard Way for a Production Kafka + ScyllaDB PipelineLearning Rust the Hard Way for a Production Kafka + ScyllaDB Pipeline
Learning Rust the Hard Way for a Production Kafka + ScyllaDB Pipeline
ScyllaDB317 views

Recently uploaded

Voice Logger - Telephony Integration Solution at Aegis by
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at AegisNirmal Sharma
39 views1 slide
handbook for web 3 adoption.pdf by
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdfLiveplex
22 views16 slides
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...Jasper Oosterveld
18 views49 slides
Data Integrity for Banking and Financial Services by
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial ServicesPrecisely
21 views26 slides
PRODUCT LISTING.pptx by
PRODUCT LISTING.pptxPRODUCT LISTING.pptx
PRODUCT LISTING.pptxangelicacueva6
14 views1 slide

Recently uploaded(20)

Voice Logger - Telephony Integration Solution at Aegis by Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma39 views
handbook for web 3 adoption.pdf by Liveplex
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdf
Liveplex22 views
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely21 views
Business Analyst Series 2023 - Week 3 Session 5 by DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10248 views
Unit 1_Lecture 2_Physical Design of IoT.pdf by StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec12 views
Case Study Copenhagen Energy and Business Central.pdf by Aitana
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdf
Aitana16 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software263 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker37 views
Special_edition_innovator_2023.pdf by WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2217 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb14 views

Database Performance at Scale Masterclass: Driver Strategies by Piotr Sarna