SlideShare a Scribd company logo
1 of 44
Top Data Modeling Mistakes
Felipe Mendes
Real-world examples of wrong data modeling
2
Felipe Mendes
● Solution Architect at ScyllaDB
● Published Author
● Linux and Open Source enthusiast
3
Agenda
● Data Modeling Guidelines
● Shooting yourself in the foot
○ Large partitions & collections 🤌
○ Hot partitions 🤌
○ Low cardinality indexes & views 🤌
○ TOMBSTONES! ☠️
● Mistakes Diagnosis & Prevention
Data Modeling
Guidelines
4
Data Modeling Guidelines
NoSQL data modeling is very simple – but SURPRISINGLY EASY to
get wrong. Typical hiccups and roadblocks include:
■ Hotspots
■ High Imbalances
■ Large partitions, rows, cells, collections…
■ Tombstones
5
Data Modeling Guidelines
General guidelines typically involve:
■ Follow a query-driven design approach
■ Proper PRIMARY KEY selection
■ Seemingly* even data distribution
■ Avoiding bad access patterns
■ And…
6
PLEASE …
7
INSTALL THE
MONITORING !
Imbalance Types
■ Driver load balancing settings
8
Queries sent from the client side perspective
Node receives much less traffic
Imbalance Types
■ Uneven Access Patterns
9
Node receives much less traffic
How queries get balanced among replicas
Imbalance Types
■ The ideal world
10
Perfect distribution!
Imbalance Types
■ Data Distribution
11
Why are imbalances bad?
Imbalances introduce:
■ Over / under-utilized resources
■ Slower replicas
■ Higher latencies
■ Inability to read data any longer
■ Worse problems under the extreme… 🥲
12
Shooting yourself in the foot
A primer on how to break things & ruin your day
Large Partitions
How large is… LARGE?
14
Large Partitions
How large is… Acceptable?
15
■ How latency sensitive are you? 😅
■ What's the average payload size?
■ Are large partitions a natural aspect?
■ How do you read from these partitions?
Large Partitions
Payload Size Row Count Partition Size
1 KB 10K ~10 MB
2 KB 10K ~20 MB
4 KB 10K ~40 MB
16
How does payload affects the partition size? Page cut off at every 1 MB =
More client-server round-trips!
17
Large Partitions
Write path re-visit:
Large Partitions
SSTable components require memory allocation:
18
Large Collections
Collections are meant for storing/denormalizing a relatively small
amount of data
19
■ Can be frozen or non-frozen
○ Frozen collections can only be updated as a whole
○ Non-frozen can be appended to (danger!)
○ (Re) Initializing a collection requires a tombstone 💀
■ Can be nested 🥲
■ Collections are stored as a single cell!
■ EXTREMELY EASY to nuke performance
Large Collections
Unlike partitions, collections are much strict in size AND nº of items
20
CREATE TABLE IF NOT EXISTS {table} (
sensor_id uuid PRIMARY KEY,
events map<timestamp, FROZEN<map<text, int>>>,
)
■ Step 1: Create a nested map
■ Step 2: (Try to) append 1 million entries
■ Step 3: Enjoy! 💣 (and see scylladb/13686)
Large Collections
As more and more items get appended, latency climbs to heaven 🌥🥲
21
Large Collections
p99 > 1s? Why? ScyllaDB Engineer Michał Chojnowski explains:
22
■ Collection cells are stored in memory as sorted vectors
■ Adding elements require a merge of two collections (old & new)
■ Adding an element has a cost proportional to the size of the
entire collection
■ Trees (instead of vectors) would improve the performance,
BUT…
■ Trees would make small collections less efficient!
Large Collections
Solution to previous data modeling:
23
CREATE TABLE IF NOT EXISTS {table} (
sensor_id uuid,
record_time timestamp,
events FROZEN<map<text, int>>,
PRIMARY KEY(sensor_id, record_time)
)
■ Move the timestamp to a clustering key
Hot Partitions
Typical hotspot sources:
24
■ Data modeling inefficiency (low cardinality)
■ Uneven application access patterns
■ Spam / Bots
■ Retry storms
Hot Partitions
ScyllaDB shard-per-core architecture makes identifying hot shards
fairly easy:
25
Hot Partitions
Tip: The number of affected shards equals the replication factor!
26
Hot Partitions
Identifying hot partitions:
27
■ Find the affected nodes / shards on monitoring
■ Use nodetool toppartitions to sample and print hit-rate
■ When unsure (or too many tables to sample): Trace
■ Isolate and remediate the problem
Low Cardinality Indexes & Views
Everyone eventually tries this 😢
28
■ Indexes or Views are essentially like regular tables
■ Same data modeling practices apply
■ DON'TS:
○ Filter all inactive users
○ Retrieve tenants by state or country
○ Implement a type-ahead use case with views or indexes
○ Try to implement an ad-hoc querying use case on top of MVs
■ But if you really… really… really… REALLY need this, then…
Low Cardinality Indexes & Views
Still avoid the index/view … 🥲 Do efficient full table scans!
29
■ Partitions are hashed to a token
■ Tokens are placed in the token ring
■ Break-down and scan the token ring!
SELECT * FROM {table} WHERE
TOKEN(pk) > ? AND
TOKEN(pk) <= ? AND
is_active = TRUE
ALLOW FILTERING
Low Cardinality Indexes & Views
30
Data Nature
Average Nº of
possible items
Large partition nº
Boolean 2 100%
Country / State 195 ~10
Status 10 2~3
Winning the lottery: Hotspots, large partitions, imbalances all in one!
Tombstones ☠️
31
Users are often surprised that deletes are actually WRITES!
■ Deleting a record is actually "writing a tombstone"
■ Tombstones (deletes) can be classified as:
○ Cell-level tombstone (DELETE val FROM table WHERE key=?)
○ Range tombstone (DELETE FROM table WHERE key=? AND ts <= ?)
○ Row tombstone (DELETE FROM table WHERE key=? AND ts=?)
○ Partition tombstone (DELETE FROM table WHERE key=?)
■ Large tombstone runs slow down the read path
■ DELETE-heavy use cases require attention
Tombstones ☠️
32
Why tombstones slow down the read path? Re-revisit ScyllaDB write
path:
Tombstones ☠️
33
Why tombstones slow down the read path? Re-revisit ScyllaDB write
path:
Tombstones ☠️
34
Why tombstones slow down the read path? Re-revisit ScyllaDB write
path:
Tombstones ☠️
35
Why tombstones slow down the read path? Re-revisit ScyllaDB write
path:
Tombstones ☠️
36
Why tombstones slow down the read path? Re-revisit ScyllaDB write
path:
Reads need to scan through all SSTables!
Effectively increasing read latencies…
Tombstones ☠️
Why tombstones slow down the read path? Re-revisit ScyllaDB write
path:
compaction
Tombstones ☠️
Latency may become unacceptable:
Or data may become entirely unreadable:
6 seconds!
Mistakes Diagnosis &
Prevention
39
Large Partitions / Cells / Collections
Easily found via system.large_* tables:
■ SELECT * FROM system.large_partitions;
■ SELECT * FROM system.large_rows;
■ SELECT * FROM system.large_cells;
■ Large Partition Hunting guide
40
Hot Partitions
Multiple ways to address:
■ When in doubt: nodetool toppartitions <keyspace> <table> <sample in ms>
■ Per Partition Rate Limit:
ALTER TABLE t WITH per_partition_rate_limit = {
'max_reads_per_second': 100,
'max_writes_per_second': 200
};
■ Client-side settings review
41
Hot Shards
■ Use the Monitoring:
○ Affected shards are on the coordinator side?
○ Affected shards are on the replica side?
■ Request shedding: --max-concurrent-requests-per-shard <n>
■ Tracing:
○ User-defined
○ Probabilistic
○ Slow Query Logging
○ Lightweight Slow Query Logging Mode
○ Woot!
42
Tombstones ☠️ Eviction
■ Be sure to select the right Compaction Strategy
43
■ Review DELETE patterns
■ Repair-based Tombstone Garbage Collection
■ New in 5.2: Empty Replica Pages
Keep in touch!
Felipe Mendes
Solution Architect
ScyllaDB
felipemendes@scylladb.com
LinkedIn

More Related Content

What's hot

Understanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksUnderstanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksJignesh Shah
 
MariaDB MaxScale
MariaDB MaxScaleMariaDB MaxScale
MariaDB MaxScaleMariaDB plc
 
Replacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDBReplacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDBScyllaDB
 
Optimizing Performance in Rust for Low-Latency Database Drivers
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 DriversScyllaDB
 
Hive Bucketing in Apache Spark with Tejas Patil
Hive Bucketing in Apache Spark with Tejas PatilHive Bucketing in Apache Spark with Tejas Patil
Hive Bucketing in Apache Spark with Tejas PatilDatabricks
 
ClickHouse Deep Dive, by Aleksei Milovidov
ClickHouse Deep Dive, by Aleksei MilovidovClickHouse Deep Dive, by Aleksei Milovidov
ClickHouse Deep Dive, by Aleksei MilovidovAltinity Ltd
 
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the CloudAmazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the CloudNoritaka Sekiyama
 
MySQL Index Cookbook
MySQL Index CookbookMySQL Index Cookbook
MySQL Index CookbookMYXPLAIN
 
How Scylla Manager Handles Backups
How Scylla Manager Handles BackupsHow Scylla Manager Handles Backups
How Scylla Manager Handles BackupsScyllaDB
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performanceoysteing
 
Advanced MySQL Query Tuning
Advanced MySQL Query TuningAdvanced MySQL Query Tuning
Advanced MySQL Query TuningAlexander Rubin
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in ActionSveta Smirnova
 
The Parquet Format and Performance Optimization Opportunities
The Parquet Format and Performance Optimization OpportunitiesThe Parquet Format and Performance Optimization Opportunities
The Parquet Format and Performance Optimization OpportunitiesDatabricks
 
MongoDB vs Scylla: Production Experience from Both Dev & Ops Standpoint at Nu...
MongoDB vs Scylla: Production Experience from Both Dev & Ops Standpoint at Nu...MongoDB vs Scylla: Production Experience from Both Dev & Ops Standpoint at Nu...
MongoDB vs Scylla: Production Experience from Both Dev & Ops Standpoint at Nu...ScyllaDB
 
Scylla Compaction Strategies
Scylla Compaction StrategiesScylla Compaction Strategies
Scylla Compaction StrategiesNadav Har'El
 
Developing Scylla Applications: Practical Tips
Developing Scylla Applications: Practical TipsDeveloping Scylla Applications: Practical Tips
Developing Scylla Applications: Practical TipsScyllaDB
 

What's hot (20)

Understanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksUnderstanding PostgreSQL LW Locks
Understanding PostgreSQL LW Locks
 
MariaDB MaxScale
MariaDB MaxScaleMariaDB MaxScale
MariaDB MaxScale
 
Replacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDBReplacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDB
 
Optimizing Performance in Rust for Low-Latency Database Drivers
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
 
Hive Bucketing in Apache Spark with Tejas Patil
Hive Bucketing in Apache Spark with Tejas PatilHive Bucketing in Apache Spark with Tejas Patil
Hive Bucketing in Apache Spark with Tejas Patil
 
MyRocks Deep Dive
MyRocks Deep DiveMyRocks Deep Dive
MyRocks Deep Dive
 
ClickHouse Deep Dive, by Aleksei Milovidov
ClickHouse Deep Dive, by Aleksei MilovidovClickHouse Deep Dive, by Aleksei Milovidov
ClickHouse Deep Dive, by Aleksei Milovidov
 
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the CloudAmazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
 
Sql query patterns, optimized
Sql query patterns, optimizedSql query patterns, optimized
Sql query patterns, optimized
 
MySQL Index Cookbook
MySQL Index CookbookMySQL Index Cookbook
MySQL Index Cookbook
 
How Scylla Manager Handles Backups
How Scylla Manager Handles BackupsHow Scylla Manager Handles Backups
How Scylla Manager Handles Backups
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
 
Advanced MySQL Query Tuning
Advanced MySQL Query TuningAdvanced MySQL Query Tuning
Advanced MySQL Query Tuning
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in Action
 
The Parquet Format and Performance Optimization Opportunities
The Parquet Format and Performance Optimization OpportunitiesThe Parquet Format and Performance Optimization Opportunities
The Parquet Format and Performance Optimization Opportunities
 
SQL Tuning 101
SQL Tuning 101SQL Tuning 101
SQL Tuning 101
 
MongoDB vs Scylla: Production Experience from Both Dev & Ops Standpoint at Nu...
MongoDB vs Scylla: Production Experience from Both Dev & Ops Standpoint at Nu...MongoDB vs Scylla: Production Experience from Both Dev & Ops Standpoint at Nu...
MongoDB vs Scylla: Production Experience from Both Dev & Ops Standpoint at Nu...
 
Scylla Compaction Strategies
Scylla Compaction StrategiesScylla Compaction Strategies
Scylla Compaction Strategies
 
PostgreSQL: Advanced indexing
PostgreSQL: Advanced indexingPostgreSQL: Advanced indexing
PostgreSQL: Advanced indexing
 
Developing Scylla Applications: Practical Tips
Developing Scylla Applications: Practical TipsDeveloping Scylla Applications: Practical Tips
Developing Scylla Applications: Practical Tips
 

Similar to Top NoSQL Data Modeling Mistakes

How to be Successful with Scylla
How to be Successful with ScyllaHow to be Successful with Scylla
How to be Successful with ScyllaScyllaDB
 
The Hows and Whys of a Distributed SQL Database - Strange Loop 2017
The Hows and Whys of a Distributed SQL Database - Strange Loop 2017The Hows and Whys of a Distributed SQL Database - Strange Loop 2017
The Hows and Whys of a Distributed SQL Database - Strange Loop 2017Alex Robinson
 
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
 
Cassandra in production
Cassandra in productionCassandra in production
Cassandra in productionvalstadsve
 
Is NoSQL The Future of Data Storage?
Is NoSQL The Future of Data Storage?Is NoSQL The Future of Data Storage?
Is NoSQL The Future of Data Storage?Saltmarch Media
 
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
 
Scylla Summit 2022: Migrating SQL Schemas for ScyllaDB: Data Modeling Best Pr...
Scylla Summit 2022: Migrating SQL Schemas for ScyllaDB: Data Modeling Best Pr...Scylla Summit 2022: Migrating SQL Schemas for ScyllaDB: Data Modeling Best Pr...
Scylla Summit 2022: Migrating SQL Schemas for ScyllaDB: Data Modeling Best Pr...ScyllaDB
 
9_Storage_Devices.pptx
9_Storage_Devices.pptx9_Storage_Devices.pptx
9_Storage_Devices.pptxJawaharPrasad3
 
MariaDB / MySQL tripping hazard and how to get out again?
MariaDB / MySQL tripping hazard and how to get out again?MariaDB / MySQL tripping hazard and how to get out again?
MariaDB / MySQL tripping hazard and how to get out again?FromDual GmbH
 
Wikimedia Content API (Strangeloop)
Wikimedia Content API (Strangeloop)Wikimedia Content API (Strangeloop)
Wikimedia Content API (Strangeloop)Eric Evans
 
Pitfalls of Object Oriented Programming
Pitfalls of Object Oriented ProgrammingPitfalls of Object Oriented Programming
Pitfalls of Object Oriented ProgrammingSlide_N
 
Latest performance changes by Scylla - Project optimus / Nolimits
Latest performance changes by Scylla - Project optimus / Nolimits Latest performance changes by Scylla - Project optimus / Nolimits
Latest performance changes by Scylla - Project optimus / Nolimits ScyllaDB
 
Simple Works Best
 Simple Works Best Simple Works Best
Simple Works BestEDB
 
Scylla Summit 2022: Making Schema Changes Safe with Raft
Scylla Summit 2022: Making Schema Changes Safe with RaftScylla Summit 2022: Making Schema Changes Safe with Raft
Scylla Summit 2022: Making Schema Changes Safe with RaftScyllaDB
 
Scylla Summit 2022: How to Migrate a Counter Table for 68 Billion Records
Scylla Summit 2022: How to Migrate a Counter Table for 68 Billion RecordsScylla Summit 2022: How to Migrate a Counter Table for 68 Billion Records
Scylla Summit 2022: How to Migrate a Counter Table for 68 Billion RecordsScyllaDB
 

Similar to Top NoSQL Data Modeling Mistakes (20)

How to be Successful with Scylla
How to be Successful with ScyllaHow to be Successful with Scylla
How to be Successful with Scylla
 
The Hows and Whys of a Distributed SQL Database - Strange Loop 2017
The Hows and Whys of a Distributed SQL Database - Strange Loop 2017The Hows and Whys of a Distributed SQL Database - Strange Loop 2017
The Hows and Whys of a Distributed SQL Database - Strange Loop 2017
 
Deep Dive on Amazon Redshift
Deep Dive on Amazon RedshiftDeep Dive on Amazon Redshift
Deep Dive on Amazon Redshift
 
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
 
Cassandra in production
Cassandra in productionCassandra in production
Cassandra in production
 
Is NoSQL The Future of Data Storage?
Is NoSQL The Future of Data Storage?Is NoSQL The Future of Data Storage?
Is NoSQL The Future of Data Storage?
 
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...
 
Scylla Summit 2022: Migrating SQL Schemas for ScyllaDB: Data Modeling Best Pr...
Scylla Summit 2022: Migrating SQL Schemas for ScyllaDB: Data Modeling Best Pr...Scylla Summit 2022: Migrating SQL Schemas for ScyllaDB: Data Modeling Best Pr...
Scylla Summit 2022: Migrating SQL Schemas for ScyllaDB: Data Modeling Best Pr...
 
Intro to Cassandra
Intro to CassandraIntro to Cassandra
Intro to Cassandra
 
9_Storage_Devices.pptx
9_Storage_Devices.pptx9_Storage_Devices.pptx
9_Storage_Devices.pptx
 
Intro to column stores
Intro to column storesIntro to column stores
Intro to column stores
 
9_Storage_Devices.pptx
9_Storage_Devices.pptx9_Storage_Devices.pptx
9_Storage_Devices.pptx
 
MariaDB / MySQL tripping hazard and how to get out again?
MariaDB / MySQL tripping hazard and how to get out again?MariaDB / MySQL tripping hazard and how to get out again?
MariaDB / MySQL tripping hazard and how to get out again?
 
Wikimedia Content API (Strangeloop)
Wikimedia Content API (Strangeloop)Wikimedia Content API (Strangeloop)
Wikimedia Content API (Strangeloop)
 
Deep Dive on Amazon Redshift
Deep Dive on Amazon RedshiftDeep Dive on Amazon Redshift
Deep Dive on Amazon Redshift
 
Pitfalls of Object Oriented Programming
Pitfalls of Object Oriented ProgrammingPitfalls of Object Oriented Programming
Pitfalls of Object Oriented Programming
 
Latest performance changes by Scylla - Project optimus / Nolimits
Latest performance changes by Scylla - Project optimus / Nolimits Latest performance changes by Scylla - Project optimus / Nolimits
Latest performance changes by Scylla - Project optimus / Nolimits
 
Simple Works Best
 Simple Works Best Simple Works Best
Simple Works Best
 
Scylla Summit 2022: Making Schema Changes Safe with Raft
Scylla Summit 2022: Making Schema Changes Safe with RaftScylla Summit 2022: Making Schema Changes Safe with Raft
Scylla Summit 2022: Making Schema Changes Safe with Raft
 
Scylla Summit 2022: How to Migrate a Counter Table for 68 Billion Records
Scylla Summit 2022: How to Migrate a Counter Table for 68 Billion RecordsScylla Summit 2022: How to Migrate a Counter Table for 68 Billion Records
Scylla Summit 2022: How to Migrate a Counter Table for 68 Billion Records
 

More from 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: 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
 
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
 
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 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
 
Overcoming Media Streaming Challenges with NoSQL
Overcoming Media Streaming Challenges with NoSQLOvercoming Media Streaming Challenges with NoSQL
Overcoming Media Streaming Challenges with NoSQLScyllaDB
 
How Optimizely (Safely) Maximizes Database Concurrency.pdf
How Optimizely (Safely) Maximizes Database Concurrency.pdfHow Optimizely (Safely) Maximizes Database Concurrency.pdf
How Optimizely (Safely) Maximizes Database Concurrency.pdfScyllaDB
 
How Development Teams Cut Costs with ScyllaDB.pdf
How Development Teams Cut Costs with ScyllaDB.pdfHow Development Teams Cut Costs with ScyllaDB.pdf
How Development Teams Cut Costs with ScyllaDB.pdfScyllaDB
 
Learning Rust the Hard Way for a Production Kafka + ScyllaDB Pipeline
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 PipelineScyllaDB
 
NoSQL at Scale: Proven Practices & Pitfalls
NoSQL at Scale: Proven Practices & PitfallsNoSQL at Scale: Proven Practices & Pitfalls
NoSQL at Scale: Proven Practices & PitfallsScyllaDB
 

More from 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: 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
 
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
 
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 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
 
Overcoming Media Streaming Challenges with NoSQL
Overcoming Media Streaming Challenges with NoSQLOvercoming Media Streaming Challenges with NoSQL
Overcoming Media Streaming Challenges with NoSQL
 
How Optimizely (Safely) Maximizes Database Concurrency.pdf
How Optimizely (Safely) Maximizes Database Concurrency.pdfHow Optimizely (Safely) Maximizes Database Concurrency.pdf
How Optimizely (Safely) Maximizes Database Concurrency.pdf
 
How Development Teams Cut Costs with ScyllaDB.pdf
How Development Teams Cut Costs with ScyllaDB.pdfHow Development Teams Cut Costs with ScyllaDB.pdf
How Development Teams Cut Costs with ScyllaDB.pdf
 
Learning Rust the Hard Way for a Production Kafka + ScyllaDB Pipeline
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
 
NoSQL at Scale: Proven Practices & Pitfalls
NoSQL at Scale: Proven Practices & PitfallsNoSQL at Scale: Proven Practices & Pitfalls
NoSQL at Scale: Proven Practices & Pitfalls
 

Recently uploaded

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Recently uploaded (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Top NoSQL Data Modeling Mistakes

  • 1. Top Data Modeling Mistakes Felipe Mendes Real-world examples of wrong data modeling
  • 2. 2 Felipe Mendes ● Solution Architect at ScyllaDB ● Published Author ● Linux and Open Source enthusiast
  • 3. 3 Agenda ● Data Modeling Guidelines ● Shooting yourself in the foot ○ Large partitions & collections 🤌 ○ Hot partitions 🤌 ○ Low cardinality indexes & views 🤌 ○ TOMBSTONES! ☠️ ● Mistakes Diagnosis & Prevention
  • 5. Data Modeling Guidelines NoSQL data modeling is very simple – but SURPRISINGLY EASY to get wrong. Typical hiccups and roadblocks include: ■ Hotspots ■ High Imbalances ■ Large partitions, rows, cells, collections… ■ Tombstones 5
  • 6. Data Modeling Guidelines General guidelines typically involve: ■ Follow a query-driven design approach ■ Proper PRIMARY KEY selection ■ Seemingly* even data distribution ■ Avoiding bad access patterns ■ And… 6
  • 8. Imbalance Types ■ Driver load balancing settings 8 Queries sent from the client side perspective Node receives much less traffic
  • 9. Imbalance Types ■ Uneven Access Patterns 9 Node receives much less traffic How queries get balanced among replicas
  • 10. Imbalance Types ■ The ideal world 10 Perfect distribution!
  • 11. Imbalance Types ■ Data Distribution 11
  • 12. Why are imbalances bad? Imbalances introduce: ■ Over / under-utilized resources ■ Slower replicas ■ Higher latencies ■ Inability to read data any longer ■ Worse problems under the extreme… 🥲 12
  • 13. Shooting yourself in the foot A primer on how to break things & ruin your day
  • 14. Large Partitions How large is… LARGE? 14
  • 15. Large Partitions How large is… Acceptable? 15 ■ How latency sensitive are you? 😅 ■ What's the average payload size? ■ Are large partitions a natural aspect? ■ How do you read from these partitions?
  • 16. Large Partitions Payload Size Row Count Partition Size 1 KB 10K ~10 MB 2 KB 10K ~20 MB 4 KB 10K ~40 MB 16 How does payload affects the partition size? Page cut off at every 1 MB = More client-server round-trips!
  • 18. Large Partitions SSTable components require memory allocation: 18
  • 19. Large Collections Collections are meant for storing/denormalizing a relatively small amount of data 19 ■ Can be frozen or non-frozen ○ Frozen collections can only be updated as a whole ○ Non-frozen can be appended to (danger!) ○ (Re) Initializing a collection requires a tombstone 💀 ■ Can be nested 🥲 ■ Collections are stored as a single cell! ■ EXTREMELY EASY to nuke performance
  • 20. Large Collections Unlike partitions, collections are much strict in size AND nº of items 20 CREATE TABLE IF NOT EXISTS {table} ( sensor_id uuid PRIMARY KEY, events map<timestamp, FROZEN<map<text, int>>>, ) ■ Step 1: Create a nested map ■ Step 2: (Try to) append 1 million entries ■ Step 3: Enjoy! 💣 (and see scylladb/13686)
  • 21. Large Collections As more and more items get appended, latency climbs to heaven 🌥🥲 21
  • 22. Large Collections p99 > 1s? Why? ScyllaDB Engineer Michał Chojnowski explains: 22 ■ Collection cells are stored in memory as sorted vectors ■ Adding elements require a merge of two collections (old & new) ■ Adding an element has a cost proportional to the size of the entire collection ■ Trees (instead of vectors) would improve the performance, BUT… ■ Trees would make small collections less efficient!
  • 23. Large Collections Solution to previous data modeling: 23 CREATE TABLE IF NOT EXISTS {table} ( sensor_id uuid, record_time timestamp, events FROZEN<map<text, int>>, PRIMARY KEY(sensor_id, record_time) ) ■ Move the timestamp to a clustering key
  • 24. Hot Partitions Typical hotspot sources: 24 ■ Data modeling inefficiency (low cardinality) ■ Uneven application access patterns ■ Spam / Bots ■ Retry storms
  • 25. Hot Partitions ScyllaDB shard-per-core architecture makes identifying hot shards fairly easy: 25
  • 26. Hot Partitions Tip: The number of affected shards equals the replication factor! 26
  • 27. Hot Partitions Identifying hot partitions: 27 ■ Find the affected nodes / shards on monitoring ■ Use nodetool toppartitions to sample and print hit-rate ■ When unsure (or too many tables to sample): Trace ■ Isolate and remediate the problem
  • 28. Low Cardinality Indexes & Views Everyone eventually tries this 😢 28 ■ Indexes or Views are essentially like regular tables ■ Same data modeling practices apply ■ DON'TS: ○ Filter all inactive users ○ Retrieve tenants by state or country ○ Implement a type-ahead use case with views or indexes ○ Try to implement an ad-hoc querying use case on top of MVs ■ But if you really… really… really… REALLY need this, then…
  • 29. Low Cardinality Indexes & Views Still avoid the index/view … 🥲 Do efficient full table scans! 29 ■ Partitions are hashed to a token ■ Tokens are placed in the token ring ■ Break-down and scan the token ring! SELECT * FROM {table} WHERE TOKEN(pk) > ? AND TOKEN(pk) <= ? AND is_active = TRUE ALLOW FILTERING
  • 30. Low Cardinality Indexes & Views 30 Data Nature Average Nº of possible items Large partition nº Boolean 2 100% Country / State 195 ~10 Status 10 2~3 Winning the lottery: Hotspots, large partitions, imbalances all in one!
  • 31. Tombstones ☠️ 31 Users are often surprised that deletes are actually WRITES! ■ Deleting a record is actually "writing a tombstone" ■ Tombstones (deletes) can be classified as: ○ Cell-level tombstone (DELETE val FROM table WHERE key=?) ○ Range tombstone (DELETE FROM table WHERE key=? AND ts <= ?) ○ Row tombstone (DELETE FROM table WHERE key=? AND ts=?) ○ Partition tombstone (DELETE FROM table WHERE key=?) ■ Large tombstone runs slow down the read path ■ DELETE-heavy use cases require attention
  • 32. Tombstones ☠️ 32 Why tombstones slow down the read path? Re-revisit ScyllaDB write path:
  • 33. Tombstones ☠️ 33 Why tombstones slow down the read path? Re-revisit ScyllaDB write path:
  • 34. Tombstones ☠️ 34 Why tombstones slow down the read path? Re-revisit ScyllaDB write path:
  • 35. Tombstones ☠️ 35 Why tombstones slow down the read path? Re-revisit ScyllaDB write path:
  • 36. Tombstones ☠️ 36 Why tombstones slow down the read path? Re-revisit ScyllaDB write path: Reads need to scan through all SSTables! Effectively increasing read latencies…
  • 37. Tombstones ☠️ Why tombstones slow down the read path? Re-revisit ScyllaDB write path: compaction
  • 38. Tombstones ☠️ Latency may become unacceptable: Or data may become entirely unreadable: 6 seconds!
  • 40. Large Partitions / Cells / Collections Easily found via system.large_* tables: ■ SELECT * FROM system.large_partitions; ■ SELECT * FROM system.large_rows; ■ SELECT * FROM system.large_cells; ■ Large Partition Hunting guide 40
  • 41. Hot Partitions Multiple ways to address: ■ When in doubt: nodetool toppartitions <keyspace> <table> <sample in ms> ■ Per Partition Rate Limit: ALTER TABLE t WITH per_partition_rate_limit = { 'max_reads_per_second': 100, 'max_writes_per_second': 200 }; ■ Client-side settings review 41
  • 42. Hot Shards ■ Use the Monitoring: ○ Affected shards are on the coordinator side? ○ Affected shards are on the replica side? ■ Request shedding: --max-concurrent-requests-per-shard <n> ■ Tracing: ○ User-defined ○ Probabilistic ○ Slow Query Logging ○ Lightweight Slow Query Logging Mode ○ Woot! 42
  • 43. Tombstones ☠️ Eviction ■ Be sure to select the right Compaction Strategy 43 ■ Review DELETE patterns ■ Repair-based Tombstone Garbage Collection ■ New in 5.2: Empty Replica Pages
  • 44. Keep in touch! Felipe Mendes Solution Architect ScyllaDB felipemendes@scylladb.com LinkedIn

Editor's Notes

  1. https://monitoring.docs.scylladb.com/stable/
  2. https://github.com/fee-mendes/masterclass-datamodeling
  3. https://docs.scylladb.com/stable/cql/types.html#collections
  4. https://github.com/scylladb/scylladb/issues/13686
  5. https://docs.scylladb.com/stable/operating-scylla/nodetool-commands/toppartitions.html
  6. https://www.scylladb.com/2017/02/13/efficient-full-table-scans-with-scylla-1-6/
  7. https://university.scylladb.com/courses/scylla-operations/lessons/scylla-manager-repair-and-tombstones/topic/tombstones/
  8. https://docs.scylladb.com/stable/troubleshooting/debugging-large-partition.html
  9. https://docs.scylladb.com/stable/cql/cql-extensions.html#per-partition-rate-limit https://monitoring.docs.scylladb.com/stable/use-monitoring/cql-optimization.html
  10. https://docs.scylladb.com/stable/using-scylla/tracing.html
  11. https://docs.scylladb.com/stable/architecture/compaction/compaction-strategies.html https://www.scylladb.com/2022/06/30/preventing-data-resurrection-with-repair-based-tombstone-garbage-collection/ https://github.com/scylladb/scylladb/commit/e9cbc9ee85c25deb5ba9ee67ffa6e3ca9f904660