SlideShare une entreprise Scribd logo
1  sur  43
Télécharger pour lire hors ligne
How to Migrate a
Counter Table for 68
Billion Records
Robert Czupioł
Senior Platform Engineer
YOUR COMPANY 

LOGO HERE
Robert Czupioł
■ Cassandra Certified Expert since 2015
■ Introduce/Manage C*/Scylla in different companies
■ Attendee at first Scylla Summit 2016
■ and 2017, 2018… :)
Senior Platform Engineer
YOUR
COMPANY 

LOGO HERE
YOUR
PHOTO 

GOES HERE
■ Dating App
■ Top-3 in West Europe
■ +100M Customers
■ 9 Scylla Clusters (in past 16 Cassandra)
■ +200TB Data
■ avg 300k req/sec
Find the people you've crossed paths with
Decision
In May 2021, let migrate to ScyllaDB
■ Targets
• TCO
• Technical dept
• Data volumen
• Latency
• Monitoring
Crossings Cluster
■ Second biggest cluster
• 48 nodes (4 CPU, 32 GB, 1TB PD-SSD)
■ Dept
• Debian 8
• Uptime +580 days
• Cassandra 2.1
■ 8 active Tables
• Crossings_count
Migrate +68B table
Type of migration
■ Offline
• Not that case
■ Online in 3 steps
• DW by ųService
• Leverage data
• Open bottle of Champaign
Leverage data
Different strategies
■ CSV
• CQLSH/DSBULK (Writetime issue)
■ SSTable
• SStableLoader (cluster stress)
• Nodetool refresh (imo best with Network Disks)
■ Dual Connect
• Scylla migrator (spark cluster)
• Own application
Counter table
■ Out of Idempotent rule
■ Only update
■ Weird delete approach
■ Different implementation in past (local and remote shards)
■ Without USING Timestamp
■ Without TTL
■ Not accurate
Counter table
■ Range of Long value
How counter works
■ Create dedicated node-counter-id (shard) for each node [RF=2]
Node
counter id
Shard’s
logical clock
Shard’s
value
A_1 0 0
B_1 1 1
NODE A
Node
counter id
Shard’s
logical clock
Shard’s
value
A_1 0 0
B_1 1 1
NODE B
Update operation
■ On node B increment by 2
■ Read the previous shard value
■ Generate the newest logical clock
■ Save new value and send to replica
Node
counter id
Shard’s
logical clock
Shard’s
value
A_1 0 0
B_1 2 3
NODE A
Node
counter id
Shard’s
logical clock
Shard’s
value
A_1 0 0
B_1 2 3
NODE B
Node B increment by 2
Update operations
■ On node A decrement by 5
■ Read the previous shard value
■ Generate the newest logical clock
■ Save new value and send to replica
Node
counter id
Shard’s
logical clock
Shard’s
value
A_1 1 -5
B_1 2 3
NODE A
Node
counter id
Shard’s
logical clock
Shard’s
value
A_1 1 -5
B_1 2 3
NODE B
Node A decrement by 5
Update operations
■ On node A decrement by 5
■ Read the previous shard value
■ Generate the newest logical clock
■ Save new value and send to replica
Node
counter id
Shard’s
logical clock
Shard’s
value
A_1 1 -5
B_1 2 3
NODE A
Node
counter id
Shard’s
logical clock
Shard’s
value
A_1 1 -5
B_1 2 3
NODE B
Node A decrement by 5
Read operations
■ While reading nodes merge the value from each shards
Value = 3 + (-5) = -2
Node
counter id
Shard’s
logical clock
Shard’s
value
A_1 1 -5
B_1 2 3
How migrate that s..tuff?
Counter migration approach
20
21 Double write
Counter migration approach
20
21
22
23
24
1
2
3
Double write
Leverage a data
Counter migration approach
20
21
22
23
24
25
26
27
1
2
3
28
29
30
Double write
Leverage a data
.. and we’ve written our
own app
Counter-migrator
■ Java
• All ųs were written in that language
• Well known
■ Spread token ring
• 6144 ranges
• select * from table where token(a) >= ? and token(a) < ?
■ Compare and set
Some pitfalls
Out of memory
■ Extend ranges
■ 68B / 6144 ~= 11M
■ Spread into 600.000 ranges ~= 100k
Out of memory
■ Extend ranges
■ 68B / 6144 ~= 11M
■ Spread into 600.000 ranges ~= 100k
■ And shuffle that ranges - remember about Shards!
Java and Spring…
■ 30sek Spring Context start
■ JVM Heap
■ Bunch of machines
Java and Spring…
■ 30sek Spring Context start
■ JVM Heap
■ Bunch of machines
■ Switch to GOLANG
Missing alerting and swap
■ 1 node goes down (w/o swap and another process)
■ Alerts not set properly
■ Hints aggressive workload
Tune driver and CL
■ Default is always wrong
■ Properly CL even ALL
■ Scylla Driver
Avoid network latency
■ Use batches
■ Increase a warning threshold not to overload journal
Result?
Result
2x n2-standard-8
Result
2x n2-standard-8
5 days
Metrics
■ API related to DB:
• 99perc 80ms to 20ms
• 90perc 50ms to 15ms
Disk space
■ Cassandra 2.1
• 48 TB
• 45% occupation
■ Scylla 4.4
• 18 TB
• 55% occupation
0 TB
5.5 TB
11 TB
16.5 TB
22 TB
Cassandra Scylla
We’ve checked if all data
exists :)
Disk space
■ MD-format
■ Aggressive compaction
■ Zstd compression
0 TB
5.5 TB
11 TB
16.5 TB
22 TB
Cassandra Scylla
Final result
■ 48 C* => 6 Scylla
■ Improve GCS cost by Incremental Snapshots
■ N2 and LocalSSD - Commitment
■ TCO REDUCED 75%
Final result
■ 48 C* => 6 Scylla
■ Improve GCS cost by Incremental Snapshots
■ N2 and LocalSSD - Commitment
■ TCO REDUCED 75%
Lesson learned
Lesson learned
■ Before migration
• Cleanup and Repair cluster
• Sometimes even compact
■ Remember about tables properties
■ Adjust scylla.yaml
• Hints window time
• max_partition_key_restrictions_per_query (or better improve ųs code)
• internode_compression
• batch_size_warn/fail
■ Improve and keep changes in IaC like Ansible playbooks
Thank you!
Stay in touch
Robert Czupioł
linkedin.com/in/robert-czupioł-2a34b394
robert.czupiol@gmail.com

Contenu connexe

Tendances

Tendances (20)

How we got to 1 millisecond latency in 99% under repair, compaction, and flus...
How we got to 1 millisecond latency in 99% under repair, compaction, and flus...How we got to 1 millisecond latency in 99% under repair, compaction, and flus...
How we got to 1 millisecond latency in 99% under repair, compaction, and flus...
 
Under the Hood of a Shard-per-Core Database Architecture
Under the Hood of a Shard-per-Core Database ArchitectureUnder the Hood of a Shard-per-Core Database Architecture
Under the Hood of a Shard-per-Core Database Architecture
 
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...
 
Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1
 
Advanced RAC troubleshooting: Network
Advanced RAC troubleshooting: NetworkAdvanced RAC troubleshooting: Network
Advanced RAC troubleshooting: Network
 
Log Structured Merge Tree
Log Structured Merge TreeLog Structured Merge Tree
Log Structured Merge Tree
 
Percona Xtrabackup - Highly Efficient Backups
Percona Xtrabackup - Highly Efficient BackupsPercona Xtrabackup - Highly Efficient Backups
Percona Xtrabackup - Highly Efficient Backups
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performance
 
Lightweight Transactions in Scylla versus Apache Cassandra
Lightweight Transactions in Scylla versus Apache CassandraLightweight Transactions in Scylla versus Apache Cassandra
Lightweight Transactions in Scylla versus Apache Cassandra
 
When is MyRocks good?
When is MyRocks good? When is MyRocks good?
When is MyRocks good?
 
Bucket your partitions wisely - Cassandra summit 2016
Bucket your partitions wisely - Cassandra summit 2016Bucket your partitions wisely - Cassandra summit 2016
Bucket your partitions wisely - Cassandra summit 2016
 
Postgresql on NFS - J.Battiato, pgday2016
Postgresql on NFS - J.Battiato, pgday2016Postgresql on NFS - J.Battiato, pgday2016
Postgresql on NFS - J.Battiato, pgday2016
 
MyRocks Deep Dive
MyRocks Deep DiveMyRocks Deep Dive
MyRocks Deep Dive
 
Performance Monitoring: Understanding Your Scylla Cluster
Performance Monitoring: Understanding Your Scylla ClusterPerformance Monitoring: Understanding Your Scylla Cluster
Performance Monitoring: Understanding Your Scylla Cluster
 
PostgreSQL on AWS: Tips & Tricks (and horror stories)
PostgreSQL on AWS: Tips & Tricks (and horror stories)PostgreSQL on AWS: Tips & Tricks (and horror stories)
PostgreSQL on AWS: Tips & Tricks (and horror stories)
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
 
MariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationMariaDB Galera Cluster presentation
MariaDB Galera Cluster presentation
 
Streaming SQL with Apache Calcite
Streaming SQL with Apache CalciteStreaming SQL with Apache Calcite
Streaming SQL with Apache Calcite
 
Kafka at Peak Performance
Kafka at Peak PerformanceKafka at Peak Performance
Kafka at Peak Performance
 
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
 

Similaire à Scylla Summit 2022: How to Migrate a Counter Table for 68 Billion Records

Scala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache sparkScala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache spark
Demi Ben-Ari
 

Similaire à Scylla Summit 2022: How to Migrate a Counter Table for 68 Billion Records (20)

Use ScyllaDB Alternator to Use Amazon DynamoDB API, Everywhere, Better, More ...
Use ScyllaDB Alternator to Use Amazon DynamoDB API, Everywhere, Better, More ...Use ScyllaDB Alternator to Use Amazon DynamoDB API, Everywhere, Better, More ...
Use ScyllaDB Alternator to Use Amazon DynamoDB API, Everywhere, Better, More ...
 
How to build TiDB
How to build TiDBHow to build TiDB
How to build TiDB
 
To Serverless and Beyond
To Serverless and BeyondTo Serverless and Beyond
To Serverless and Beyond
 
How Opera Syncs Tens of Millions of Browsers and Sleeps Well at Night
How Opera Syncs Tens of Millions of Browsers and Sleeps Well at NightHow Opera Syncs Tens of Millions of Browsers and Sleeps Well at Night
How Opera Syncs Tens of Millions of Browsers and Sleeps Well at Night
 
Bringing code to the data: from MySQL to RocksDB for high volume searches
Bringing code to the data: from MySQL to RocksDB for high volume searchesBringing code to the data: from MySQL to RocksDB for high volume searches
Bringing code to the data: from MySQL to RocksDB for high volume searches
 
TiDB vs Aurora.pdf
TiDB vs Aurora.pdfTiDB vs Aurora.pdf
TiDB vs Aurora.pdf
 
Scala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache sparkScala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache spark
 
How to be Successful with Scylla
How to be Successful with ScyllaHow to be Successful with Scylla
How to be Successful with Scylla
 
Scylla Summit 2018: Make Scylla Fast Again! Find out how using Tools, Talent,...
Scylla Summit 2018: Make Scylla Fast Again! Find out how using Tools, Talent,...Scylla Summit 2018: Make Scylla Fast Again! Find out how using Tools, Talent,...
Scylla Summit 2018: Make Scylla Fast Again! Find out how using Tools, Talent,...
 
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...
 
Aurora Serverless, 서버리스 RDB의 서막 - 트랙2, Community Day 2018 re:Invent 특집
Aurora Serverless, 서버리스 RDB의 서막 - 트랙2, Community Day 2018 re:Invent 특집Aurora Serverless, 서버리스 RDB의 서막 - 트랙2, Community Day 2018 re:Invent 특집
Aurora Serverless, 서버리스 RDB의 서막 - 트랙2, Community Day 2018 re:Invent 특집
 
Sharding Methods for MongoDB
Sharding Methods for MongoDBSharding Methods for MongoDB
Sharding Methods for MongoDB
 
Scale Relational Database with NewSQL
Scale Relational Database with NewSQLScale Relational Database with NewSQL
Scale Relational Database with NewSQL
 
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
 
What Kiwi.com Has Learned Running ScyllaDB and Go
What Kiwi.com Has Learned Running ScyllaDB and GoWhat Kiwi.com Has Learned Running ScyllaDB and Go
What Kiwi.com Has Learned Running ScyllaDB and Go
 
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...
 
HBaseConEast2016: Splice machine open source rdbms
HBaseConEast2016: Splice machine open source rdbmsHBaseConEast2016: Splice machine open source rdbms
HBaseConEast2016: Splice machine open source rdbms
 
From Postgres to ScyllaDB: Migration Strategies and Performance Gains
From Postgres to ScyllaDB: Migration Strategies and Performance GainsFrom Postgres to ScyllaDB: Migration Strategies and Performance Gains
From Postgres to ScyllaDB: Migration Strategies and Performance Gains
 
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
 
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streaming
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to StreamingBravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streaming
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streaming
 

Plus de ScyllaDB

Plus 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 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
 
Top NoSQL Data Modeling Mistakes
Top NoSQL Data Modeling MistakesTop NoSQL Data Modeling Mistakes
Top NoSQL Data Modeling Mistakes
 

Dernier

Dernier (20)

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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
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?
 

Scylla Summit 2022: How to Migrate a Counter Table for 68 Billion Records

  • 1. How to Migrate a Counter Table for 68 Billion Records Robert Czupioł Senior Platform Engineer YOUR COMPANY 
 LOGO HERE
  • 2. Robert Czupioł ■ Cassandra Certified Expert since 2015 ■ Introduce/Manage C*/Scylla in different companies ■ Attendee at first Scylla Summit 2016 ■ and 2017, 2018… :) Senior Platform Engineer YOUR COMPANY 
 LOGO HERE YOUR PHOTO 
 GOES HERE
  • 3. ■ Dating App ■ Top-3 in West Europe ■ +100M Customers ■ 9 Scylla Clusters (in past 16 Cassandra) ■ +200TB Data ■ avg 300k req/sec Find the people you've crossed paths with
  • 4. Decision In May 2021, let migrate to ScyllaDB ■ Targets • TCO • Technical dept • Data volumen • Latency • Monitoring
  • 5. Crossings Cluster ■ Second biggest cluster • 48 nodes (4 CPU, 32 GB, 1TB PD-SSD) ■ Dept • Debian 8 • Uptime +580 days • Cassandra 2.1 ■ 8 active Tables • Crossings_count
  • 7. Type of migration ■ Offline • Not that case ■ Online in 3 steps • DW by ųService • Leverage data • Open bottle of Champaign
  • 9. Different strategies ■ CSV • CQLSH/DSBULK (Writetime issue) ■ SSTable • SStableLoader (cluster stress) • Nodetool refresh (imo best with Network Disks) ■ Dual Connect • Scylla migrator (spark cluster) • Own application
  • 10. Counter table ■ Out of Idempotent rule ■ Only update ■ Weird delete approach ■ Different implementation in past (local and remote shards) ■ Without USING Timestamp ■ Without TTL ■ Not accurate
  • 11. Counter table ■ Range of Long value
  • 12. How counter works ■ Create dedicated node-counter-id (shard) for each node [RF=2] Node counter id Shard’s logical clock Shard’s value A_1 0 0 B_1 1 1 NODE A Node counter id Shard’s logical clock Shard’s value A_1 0 0 B_1 1 1 NODE B
  • 13. Update operation ■ On node B increment by 2 ■ Read the previous shard value ■ Generate the newest logical clock ■ Save new value and send to replica Node counter id Shard’s logical clock Shard’s value A_1 0 0 B_1 2 3 NODE A Node counter id Shard’s logical clock Shard’s value A_1 0 0 B_1 2 3 NODE B Node B increment by 2
  • 14. Update operations ■ On node A decrement by 5 ■ Read the previous shard value ■ Generate the newest logical clock ■ Save new value and send to replica Node counter id Shard’s logical clock Shard’s value A_1 1 -5 B_1 2 3 NODE A Node counter id Shard’s logical clock Shard’s value A_1 1 -5 B_1 2 3 NODE B Node A decrement by 5
  • 15. Update operations ■ On node A decrement by 5 ■ Read the previous shard value ■ Generate the newest logical clock ■ Save new value and send to replica Node counter id Shard’s logical clock Shard’s value A_1 1 -5 B_1 2 3 NODE A Node counter id Shard’s logical clock Shard’s value A_1 1 -5 B_1 2 3 NODE B Node A decrement by 5
  • 16. Read operations ■ While reading nodes merge the value from each shards Value = 3 + (-5) = -2 Node counter id Shard’s logical clock Shard’s value A_1 1 -5 B_1 2 3
  • 17. How migrate that s..tuff?
  • 21.
  • 22. .. and we’ve written our own app
  • 23. Counter-migrator ■ Java • All ųs were written in that language • Well known ■ Spread token ring • 6144 ranges • select * from table where token(a) >= ? and token(a) < ? ■ Compare and set
  • 25. Out of memory ■ Extend ranges ■ 68B / 6144 ~= 11M ■ Spread into 600.000 ranges ~= 100k
  • 26. Out of memory ■ Extend ranges ■ 68B / 6144 ~= 11M ■ Spread into 600.000 ranges ~= 100k ■ And shuffle that ranges - remember about Shards!
  • 27. Java and Spring… ■ 30sek Spring Context start ■ JVM Heap ■ Bunch of machines
  • 28. Java and Spring… ■ 30sek Spring Context start ■ JVM Heap ■ Bunch of machines ■ Switch to GOLANG
  • 29. Missing alerting and swap ■ 1 node goes down (w/o swap and another process) ■ Alerts not set properly ■ Hints aggressive workload
  • 30. Tune driver and CL ■ Default is always wrong ■ Properly CL even ALL ■ Scylla Driver
  • 31. Avoid network latency ■ Use batches ■ Increase a warning threshold not to overload journal
  • 35. Metrics ■ API related to DB: • 99perc 80ms to 20ms • 90perc 50ms to 15ms
  • 36. Disk space ■ Cassandra 2.1 • 48 TB • 45% occupation ■ Scylla 4.4 • 18 TB • 55% occupation 0 TB 5.5 TB 11 TB 16.5 TB 22 TB Cassandra Scylla
  • 37. We’ve checked if all data exists :)
  • 38. Disk space ■ MD-format ■ Aggressive compaction ■ Zstd compression 0 TB 5.5 TB 11 TB 16.5 TB 22 TB Cassandra Scylla
  • 39. Final result ■ 48 C* => 6 Scylla ■ Improve GCS cost by Incremental Snapshots ■ N2 and LocalSSD - Commitment ■ TCO REDUCED 75%
  • 40. Final result ■ 48 C* => 6 Scylla ■ Improve GCS cost by Incremental Snapshots ■ N2 and LocalSSD - Commitment ■ TCO REDUCED 75%
  • 42. Lesson learned ■ Before migration • Cleanup and Repair cluster • Sometimes even compact ■ Remember about tables properties ■ Adjust scylla.yaml • Hints window time • max_partition_key_restrictions_per_query (or better improve ųs code) • internode_compression • batch_size_warn/fail ■ Improve and keep changes in IaC like Ansible playbooks
  • 43. Thank you! Stay in touch Robert Czupioł linkedin.com/in/robert-czupioł-2a34b394 robert.czupiol@gmail.com