SlideShare uma empresa Scribd logo
1 de 19
What is Compaction?
Kazutaka Tomita (INTHEFOREST Co., Ltd.)
Who is this guy?
Kazutaka Tomita (@railute)
• INTHEFOREST Co., Ltd. CEO/CTO
• Consulting for Apache Cassandra and Apache Spark Systems
• Supporting for Cassandra in Japan
• an organizer of Cassandra Summit JPN
Specialty
• RDBMS (Oracle,SQLServer,MySQL,PostgreSQL)
• Apache Cassandra
• Apache Spark
• Apache Hadoop with YARN
• And other NoSQL
• NLP and Text mining for Japanese
Agenda
 Overview of Compaction.
 Compaction Do.
Overview of Compaction.
• Why is the compaction done ?
• When is the compaction done?
• What type is the compaction?
Three points of Cassandra’s Compaction.
Why is the compaction done ?
So, We must purge duplicate or overwritten or deleted data and tombstones.
The most important thing :
The SSTable is immutable.
Writing System for Apache Cassandra
for your reference
memtable
Memory
Disk
Commit Log
Coordinator
node
Flush
SSTable
For
local
1st
NoWriting
node is
alive.
YES
Write Hinted
Sent messages to other node
Writing operation
Receive messages from coordinator node
2nd
memtable memtable
SSTable SSTable
Compacion
Close
YES
No
Sort by token
When is the compaction done?
1.Manually
2.Running in the background
When is the compaction done?
1.Manually
1. nodetool compact
Forces a major compaction on one or more tables.
By size tiered compaction, a major compaction combines each of the
pools of repaired and unrepaired SSTables into one repaired and one
unreparied SSTable.
2. nodetool scrub
Rebuild SSTables for one or more Cassandra tables.
3. nodetool cleanup
Cleans up keyspaces and partition keys no longer belonging to a node.
Use this command to remove unwanted data after adding a new node
to the cluster. Cassandra does not automatically remove data from
nodes that lose part of their partition range to a newly added node.
4. nodetool upgradesstables
Rewrites SSTables for tables that are not running the current version
of Cassandra.
When is the compaction done?
2. Running in the background
1.daemon started
2.after flashing memtables
3.after streaming
4.enable auto compaction by nodetool
5.set compaction threshold by nodetool
What type is the compaction?
1. Minor
2. Major
3. Single-sstable compactions
4. Anti compaction
What type is the compaction?
1. Minor
This compaction runs automatically in the background.
• daemon started
• after flashing memtables
• after streaming
What type is the compaction?
2. Major
This compaction is only called by size tiered compaction.
cf.)
org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy#getMaximalTask
The Other compaction is called by “nodetool compact”, but major compaction is not executed.
*n. minor compaction is executed.
cf.)
org.apache.cassandra.db.compaction.DateTieredCompactionStrategy#getMaximalTask
org.apache.cassandra.db.compaction.LeveledCompactionStrategy#getMaximalTask
What type is the compaction?
3. Single-sstable compactions
This Compaction is executed one by one every SSTable.
nodetool upgradesstables
nodetool scrub
nodetool cleanup
What type is the compaction?
4. Anti compaction
This Compaction is for incremental repairs.
After executing incremantal repairs, An anticompaction is called.
*After 2.1
Compaction Strategy
1. SizeTieredCompactionStrategy
For write-intensive workloads
2. LeveledCompactionStrategy
For read-intensive workloads
3. DateTieredCompactionStrategy
For time series data and expiring (TTL) data
Size Tiered Compaction Strategy
When Some SSTables became the similar size, they are merged.
(default is 4.)
SSTable SSTable SSTable SSTable
SSTable SSTable
SSTable SSTable
SSTable
Leveled Compaction Strategy
SSTable SSTable SSTable SSTable SSTable SSTableLebel0
SSTableLebel1 SSTable SSTable
SSTableLebel2 SSTable
The data which
isn't read so much.
DateTieredCompactionStrategy
Default:1hour
The basic idea of DTCS is to group SSTables in windows based on how old the data is in the SSTable.
sstable sstable sstable sstable
sstable
windows
windows
now
sstable
4 sstables 4 sstables
Merge SSTable by Compaction
When Some SSTables became the similar size, they are merged.
(default is 4.)
Name: John
Address: Osaka Address: Tokyo
Tel: xxx-xxx
ages: 20
Name: John
Address: Tokyo
ages: 20

Mais conteúdo relacionado

Mais procurados

The columnar roadmap: Apache Parquet and Apache Arrow
The columnar roadmap: Apache Parquet and Apache ArrowThe columnar roadmap: Apache Parquet and Apache Arrow
The columnar roadmap: Apache Parquet and Apache Arrow
DataWorks Summit
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
Dvir Volk
 

Mais procurados (20)

Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
 
Apache Spark Architecture
Apache Spark ArchitectureApache Spark Architecture
Apache Spark Architecture
 
Adaptive Query Execution: Speeding Up Spark SQL at Runtime
Adaptive Query Execution: Speeding Up Spark SQL at RuntimeAdaptive Query Execution: Speeding Up Spark SQL at Runtime
Adaptive Query Execution: Speeding Up Spark SQL at Runtime
 
MongoDB Configパラメータ解説
MongoDB Configパラメータ解説MongoDB Configパラメータ解説
MongoDB Configパラメータ解説
 
Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das
Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das
Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das
 
Jvm tuning for low latency application & Cassandra
Jvm tuning for low latency application & CassandraJvm tuning for low latency application & Cassandra
Jvm tuning for low latency application & Cassandra
 
MyRocks Deep Dive
MyRocks Deep DiveMyRocks Deep Dive
MyRocks Deep Dive
 
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
 
The columnar roadmap: Apache Parquet and Apache Arrow
The columnar roadmap: Apache Parquet and Apache ArrowThe columnar roadmap: Apache Parquet and Apache Arrow
The columnar roadmap: Apache Parquet and Apache Arrow
 
Improving Apache Spark's Reliability with DataSourceV2
Improving Apache Spark's Reliability with DataSourceV2Improving Apache Spark's Reliability with DataSourceV2
Improving Apache Spark's Reliability with DataSourceV2
 
Introduction VAUUM, Freezing, XID wraparound
Introduction VAUUM, Freezing, XID wraparoundIntroduction VAUUM, Freezing, XID wraparound
Introduction VAUUM, Freezing, XID wraparound
 
Rds data lake @ Robinhood
Rds data lake @ Robinhood Rds data lake @ Robinhood
Rds data lake @ Robinhood
 
Hyperspace for Delta Lake
Hyperspace for Delta LakeHyperspace for Delta Lake
Hyperspace for Delta Lake
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Batch Processing at Scale with Flink & Iceberg
Batch Processing at Scale with Flink & IcebergBatch Processing at Scale with Flink & Iceberg
Batch Processing at Scale with Flink & Iceberg
 
Apache Iceberg - A Table Format for Hige Analytic Datasets
Apache Iceberg - A Table Format for Hige Analytic DatasetsApache Iceberg - A Table Format for Hige Analytic Datasets
Apache Iceberg - A Table Format for Hige Analytic Datasets
 
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
Exactly-Once Financial Data Processing at Scale with Flink and PinotExactly-Once Financial Data Processing at Scale with Flink and Pinot
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
 
Cassandra Introduction & Features
Cassandra Introduction & FeaturesCassandra Introduction & Features
Cassandra Introduction & Features
 
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark ApplicationsTop 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
 
Building robust CDC pipeline with Apache Hudi and Debezium
Building robust CDC pipeline with Apache Hudi and DebeziumBuilding robust CDC pipeline with Apache Hudi and Debezium
Building robust CDC pipeline with Apache Hudi and Debezium
 

Destaque

Destaque (15)

Cassandra 2.1 boot camp, Compaction
Cassandra 2.1 boot camp, CompactionCassandra 2.1 boot camp, Compaction
Cassandra 2.1 boot camp, Compaction
 
Cassandra3.0
Cassandra3.0Cassandra3.0
Cassandra3.0
 
Compaction, Compaction Everywhere
Compaction, Compaction EverywhereCompaction, Compaction Everywhere
Compaction, Compaction Everywhere
 
The Missing Manual for Leveled Compaction Strategy (Wei Deng & Ryan Svihla, D...
The Missing Manual for Leveled Compaction Strategy (Wei Deng & Ryan Svihla, D...The Missing Manual for Leveled Compaction Strategy (Wei Deng & Ryan Svihla, D...
The Missing Manual for Leveled Compaction Strategy (Wei Deng & Ryan Svihla, D...
 
Cassandra v3.0 at Rakuten meet-up on 12/2/2015
Cassandra v3.0 at Rakuten meet-up on 12/2/2015Cassandra v3.0 at Rakuten meet-up on 12/2/2015
Cassandra v3.0 at Rakuten meet-up on 12/2/2015
 
Cassandra Basics, Counters and Time Series Modeling
Cassandra Basics, Counters and Time Series ModelingCassandra Basics, Counters and Time Series Modeling
Cassandra Basics, Counters and Time Series Modeling
 
MyRocks: табличный движок для MySQL на основе RocksDB
MyRocks: табличный движок для MySQL на основе RocksDBMyRocks: табличный движок для MySQL на основе RocksDB
MyRocks: табличный движок для MySQL на основе RocksDB
 
Data Modeling with Cassandra and Time Series Data
Data Modeling with Cassandra and Time Series DataData Modeling with Cassandra and Time Series Data
Data Modeling with Cassandra and Time Series Data
 
Stratio's Cassandra Lucene index: Geospatial Use Cases (Andrés de la Peña & J...
Stratio's Cassandra Lucene index: Geospatial Use Cases (Andrés de la Peña & J...Stratio's Cassandra Lucene index: Geospatial Use Cases (Andrés de la Peña & J...
Stratio's Cassandra Lucene index: Geospatial Use Cases (Andrés de la Peña & J...
 
Why does my choice of storage matter with cassandra?
Why does my choice of storage matter with cassandra?Why does my choice of storage matter with cassandra?
Why does my choice of storage matter with cassandra?
 
DataStax: Extreme Cassandra Optimization: The Sequel
DataStax: Extreme Cassandra Optimization: The SequelDataStax: Extreme Cassandra Optimization: The Sequel
DataStax: Extreme Cassandra Optimization: The Sequel
 
A Cassandra + Solr + Spark Love Triangle Using DataStax Enterprise
A Cassandra + Solr + Spark Love Triangle Using DataStax EnterpriseA Cassandra + Solr + Spark Love Triangle Using DataStax Enterprise
A Cassandra + Solr + Spark Love Triangle Using DataStax Enterprise
 
Cassandra compaction
Cassandra compactionCassandra compaction
Cassandra compaction
 
Cassandra model
Cassandra modelCassandra model
Cassandra model
 
Cassandra for Sysadmins
Cassandra for SysadminsCassandra for Sysadmins
Cassandra for Sysadmins
 

Semelhante a Cassandra compaction

How to randomly access data in close-to-RAM speeds but a lower cost with SSD’...
How to randomly access data in close-to-RAM speeds but a lower cost with SSD’...How to randomly access data in close-to-RAM speeds but a lower cost with SSD’...
How to randomly access data in close-to-RAM speeds but a lower cost with SSD’...
JAXLondon2014
 
Methods of Sharding MySQL
Methods of Sharding MySQLMethods of Sharding MySQL
Methods of Sharding MySQL
Laine Campbell
 

Semelhante a Cassandra compaction (20)

How to randomly access data in close-to-RAM speeds but a lower cost with SSD’...
How to randomly access data in close-to-RAM speeds but a lower cost with SSD’...How to randomly access data in close-to-RAM speeds but a lower cost with SSD’...
How to randomly access data in close-to-RAM speeds but a lower cost with SSD’...
 
SSDs, IMDGs and All the Rest - Jax London
SSDs, IMDGs and All the Rest - Jax LondonSSDs, IMDGs and All the Rest - Jax London
SSDs, IMDGs and All the Rest - Jax London
 
Methods of Sharding MySQL
Methods of Sharding MySQLMethods of Sharding MySQL
Methods of Sharding MySQL
 
Real-Time Analytics with Kafka, Cassandra and Storm
Real-Time Analytics with Kafka, Cassandra and StormReal-Time Analytics with Kafka, Cassandra and Storm
Real-Time Analytics with Kafka, Cassandra and Storm
 
Mysql talk
Mysql talkMysql talk
Mysql talk
 
Running 400-node Cassandra + Spark Clusters in Azure (Anubhav Kale, Microsoft...
Running 400-node Cassandra + Spark Clusters in Azure (Anubhav Kale, Microsoft...Running 400-node Cassandra + Spark Clusters in Azure (Anubhav Kale, Microsoft...
Running 400-node Cassandra + Spark Clusters in Azure (Anubhav Kale, Microsoft...
 
PHP Backends for Real-Time User Interaction using Apache Storm.
PHP Backends for Real-Time User Interaction using Apache Storm.PHP Backends for Real-Time User Interaction using Apache Storm.
PHP Backends for Real-Time User Interaction using Apache Storm.
 
Leverage Mesos for running Spark Streaming production jobs by Iulian Dragos a...
Leverage Mesos for running Spark Streaming production jobs by Iulian Dragos a...Leverage Mesos for running Spark Streaming production jobs by Iulian Dragos a...
Leverage Mesos for running Spark Streaming production jobs by Iulian Dragos a...
 
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...
 
The Automation Factory
The Automation FactoryThe Automation Factory
The Automation Factory
 
Apache Cassandra Lunch #96: Apache Cassandra Change Data Capture (CDC) Strate...
Apache Cassandra Lunch #96: Apache Cassandra Change Data Capture (CDC) Strate...Apache Cassandra Lunch #96: Apache Cassandra Change Data Capture (CDC) Strate...
Apache Cassandra Lunch #96: Apache Cassandra Change Data Capture (CDC) Strate...
 
Memory, Big Data, NoSQL and Virtualization
Memory, Big Data, NoSQL and VirtualizationMemory, Big Data, NoSQL and Virtualization
Memory, Big Data, NoSQL and Virtualization
 
Riak add presentation
Riak add presentationRiak add presentation
Riak add presentation
 
Scala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala TaiwanScala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala Taiwan
 
A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...
A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...
A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...
 
Running Applications on the NetBSD Rump Kernel by Justin Cormack
Running Applications on the NetBSD Rump Kernel by Justin Cormack Running Applications on the NetBSD Rump Kernel by Justin Cormack
Running Applications on the NetBSD Rump Kernel by Justin Cormack
 
Storm presentation
Storm presentationStorm presentation
Storm presentation
 
London Spark Meetup Project Tungsten Oct 12 2015
London Spark Meetup Project Tungsten Oct 12 2015London Spark Meetup Project Tungsten Oct 12 2015
London Spark Meetup Project Tungsten Oct 12 2015
 
Cassandra at Pollfish
Cassandra at PollfishCassandra at Pollfish
Cassandra at Pollfish
 
Cassandra at Pollfish
Cassandra at PollfishCassandra at Pollfish
Cassandra at Pollfish
 

Mais de Kazutaka Tomita (14)

The rethinkingofrepair
The rethinkingofrepairThe rethinkingofrepair
The rethinkingofrepair
 
Apache cassandra nio
Apache cassandra nioApache cassandra nio
Apache cassandra nio
 
Apache Cassandra 入門編
Apache Cassandra 入門編Apache Cassandra 入門編
Apache Cassandra 入門編
 
Apache cassandra 最前線
Apache cassandra 最前線Apache cassandra 最前線
Apache cassandra 最前線
 
Apache sparkとapache cassandraで行うテキスト解析
Apache sparkとapache cassandraで行うテキスト解析Apache sparkとapache cassandraで行うテキスト解析
Apache sparkとapache cassandraで行うテキスト解析
 
Cassandra2017
Cassandra2017Cassandra2017
Cassandra2017
 
Apache cassandraと apache sparkで作るデータ解析プラットフォーム
Apache cassandraと apache sparkで作るデータ解析プラットフォームApache cassandraと apache sparkで作るデータ解析プラットフォーム
Apache cassandraと apache sparkで作るデータ解析プラットフォーム
 
米国の事例で学ぶCassandra
米国の事例で学ぶCassandra米国の事例で学ぶCassandra
米国の事例で学ぶCassandra
 
Cassandra12to20
Cassandra12to20Cassandra12to20
Cassandra12to20
 
Cassandraのバックアップと運用を考える
Cassandraのバックアップと運用を考えるCassandraのバックアップと運用を考える
Cassandraのバックアップと運用を考える
 
What is row level isolation on cassandra
What is row level isolation on cassandraWhat is row level isolation on cassandra
What is row level isolation on cassandra
 
Cassandra0.7
Cassandra0.7Cassandra0.7
Cassandra0.7
 
Gossip事始め
Gossip事始めGossip事始め
Gossip事始め
 
Consistency level
Consistency levelConsistency level
Consistency level
 

Último

Último (20)

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
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
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...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
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...
 
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...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

Cassandra compaction

  • 1. What is Compaction? Kazutaka Tomita (INTHEFOREST Co., Ltd.)
  • 2. Who is this guy? Kazutaka Tomita (@railute) • INTHEFOREST Co., Ltd. CEO/CTO • Consulting for Apache Cassandra and Apache Spark Systems • Supporting for Cassandra in Japan • an organizer of Cassandra Summit JPN Specialty • RDBMS (Oracle,SQLServer,MySQL,PostgreSQL) • Apache Cassandra • Apache Spark • Apache Hadoop with YARN • And other NoSQL • NLP and Text mining for Japanese
  • 3. Agenda  Overview of Compaction.  Compaction Do.
  • 4. Overview of Compaction. • Why is the compaction done ? • When is the compaction done? • What type is the compaction? Three points of Cassandra’s Compaction.
  • 5. Why is the compaction done ? So, We must purge duplicate or overwritten or deleted data and tombstones. The most important thing : The SSTable is immutable.
  • 6. Writing System for Apache Cassandra for your reference memtable Memory Disk Commit Log Coordinator node Flush SSTable For local 1st NoWriting node is alive. YES Write Hinted Sent messages to other node Writing operation Receive messages from coordinator node 2nd memtable memtable SSTable SSTable Compacion Close YES No Sort by token
  • 7. When is the compaction done? 1.Manually 2.Running in the background
  • 8. When is the compaction done? 1.Manually 1. nodetool compact Forces a major compaction on one or more tables. By size tiered compaction, a major compaction combines each of the pools of repaired and unrepaired SSTables into one repaired and one unreparied SSTable. 2. nodetool scrub Rebuild SSTables for one or more Cassandra tables. 3. nodetool cleanup Cleans up keyspaces and partition keys no longer belonging to a node. Use this command to remove unwanted data after adding a new node to the cluster. Cassandra does not automatically remove data from nodes that lose part of their partition range to a newly added node. 4. nodetool upgradesstables Rewrites SSTables for tables that are not running the current version of Cassandra.
  • 9. When is the compaction done? 2. Running in the background 1.daemon started 2.after flashing memtables 3.after streaming 4.enable auto compaction by nodetool 5.set compaction threshold by nodetool
  • 10. What type is the compaction? 1. Minor 2. Major 3. Single-sstable compactions 4. Anti compaction
  • 11. What type is the compaction? 1. Minor This compaction runs automatically in the background. • daemon started • after flashing memtables • after streaming
  • 12. What type is the compaction? 2. Major This compaction is only called by size tiered compaction. cf.) org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy#getMaximalTask The Other compaction is called by “nodetool compact”, but major compaction is not executed. *n. minor compaction is executed. cf.) org.apache.cassandra.db.compaction.DateTieredCompactionStrategy#getMaximalTask org.apache.cassandra.db.compaction.LeveledCompactionStrategy#getMaximalTask
  • 13. What type is the compaction? 3. Single-sstable compactions This Compaction is executed one by one every SSTable. nodetool upgradesstables nodetool scrub nodetool cleanup
  • 14. What type is the compaction? 4. Anti compaction This Compaction is for incremental repairs. After executing incremantal repairs, An anticompaction is called. *After 2.1
  • 15. Compaction Strategy 1. SizeTieredCompactionStrategy For write-intensive workloads 2. LeveledCompactionStrategy For read-intensive workloads 3. DateTieredCompactionStrategy For time series data and expiring (TTL) data
  • 16. Size Tiered Compaction Strategy When Some SSTables became the similar size, they are merged. (default is 4.) SSTable SSTable SSTable SSTable SSTable SSTable SSTable SSTable SSTable
  • 17. Leveled Compaction Strategy SSTable SSTable SSTable SSTable SSTable SSTableLebel0 SSTableLebel1 SSTable SSTable SSTableLebel2 SSTable The data which isn't read so much.
  • 18. DateTieredCompactionStrategy Default:1hour The basic idea of DTCS is to group SSTables in windows based on how old the data is in the SSTable. sstable sstable sstable sstable sstable windows windows now sstable 4 sstables 4 sstables
  • 19. Merge SSTable by Compaction When Some SSTables became the similar size, they are merged. (default is 4.) Name: John Address: Osaka Address: Tokyo Tel: xxx-xxx ages: 20 Name: John Address: Tokyo ages: 20