SlideShare a Scribd company logo
1 of 52
The Apache Cassandra
   storage engine
          Sylvain Lebresne
    (sylvain@             .com)


      FOSDEM ’12, Brussels
1. What is Apache Cassandra

2. Data Model

3. The storage engine
1. What is Apache Cassandra

2. Data Model

3. The storage engine
about:project

• Distributed data store aimed at big data
• Apache project since 2010.
• Version 1.0 released last October.
• Proven in production (Netflix, Twitter,
  Reddit, Cisco, ...). Largest know cluster has
  over 300TB in over 400 machines.
Apache Cassandra
Apache Cassandra
A database:
Apache Cassandra
A database:
• distributed / decentralized
Apache Cassandra
A database:
• distributed / decentralized
• replicated & durable
Apache Cassandra
A database:
• distributed / decentralized
• replicated & durable
• scalable / elastic
Apache Cassandra
A database:
• distributed / decentralized
• replicated & durable
• scalable / elastic
Apache Cassandra
A database:
• distributed / decentralized
• replicated & durable
• scalable / elastic
• fault-tolerant / no SPOF
Apache Cassandra
A database:
• distributed / decentralized
• replicated & durable
• scalable / elastic
• fault-tolerant / no SPOF
• highly available
Apache Cassandra
A database:
• distributed / decentralized
• replicated & durable
• scalable / elastic
• fault-tolerant / no SPOF
• highly available
Apache Cassandra
A database:
• distributed / decentralized
• replicated & durable
• scalable / elastic
• fault-tolerant / no SPOF
• highly available
• data center aware


          US
                                Europe
1. What is Apache Cassandra

2. Data Model

3. The storage engine
Data Model


• Not SQL (no transaction, nor joins) but
  more than Key/Value.
• Inspired by Google BigTable
• Column families based.
Ex: user profiles
        “For each user, holds profile infos”


                   50e8-e29b
                  birth_year   1994

                   fname       Justin

                   lname       Bieber




Users
Ex: user profiles
        “For each user, holds profile infos”


          50e8-e29b             2ab1-f1b7
         birth_year   1994     birth_year     1978

          fname       Justin     email      a@kutcher.com



          lname       Bieber    fname        Ashton

                                lname       Kutcher




Users
Ex: user’s Tweets
           “For each user, tweets he has made”

                        50e8-e29b




Timeline
Ex: user’s Tweets
           “For each user, tweets he has made”

                          50e8-e29b
                            @LiveLoveKary glad you had
                      0     a good birthday #muchlove




Timeline
Ex: user’s Tweets
           “For each user, tweets he has made”

                          50e8-e29b
                            @NickDeMoura happy bday
                      1     my dude.


                            @LiveLoveKary glad you had
                      0     a good birthday #muchlove




Timeline
Ex: user’s Tweets
           “For each user, tweets he has made”

                          50e8-e29b
                            @MickyArison @miamiHEAT
                      2     thanks for the gam tonight


                            @NickDeMoura happy bday
                      1     my dude.


                            @LiveLoveKary glad you had
                      0     a good birthday #muchlove




Timeline
Ex: user’s Tweets
           “For each user, tweets he has made”

                          50e8-e29b
                            still a little tired. back in the
                      3     studio today with Timbaland


                            @MickyArison @miamiHEAT
                      2     thanks for the gam tonight


                            @NickDeMoura happy bday
                      1     my dude.


                            @LiveLoveKary glad you had
                      0     a good birthday #muchlove




Timeline
There’s more


• Secondary indexes
• Distributed counters
• Composite columns
1. What is Apache Cassandra

2. Data Model

3. The storage engine
Goal


• Writes are harder than reads to scale
• Spinning disks aren’t good with random I/O
• Goal: minimize random I/O
A write’s journal
 write( k1 , c1:v1 )

                                                Memory




                                   Memtable




Commit log



                                              Hard drive
A write’s journal
 write( k1 , c1:v1 )

                                                    Memory
                            k1 c1:v1




                                       Memtable



     k1 c1:v1




Commit log



                                                  Hard drive
A write’s journal
ack
                                 Memory
                k1 c1:v1




k1 c1:v1




                               Hard drive
A write’s journal
write( k1 , c2:v2 )

                                              Memory
                           k1 c1:v1 c2:v2




    k1 c1:v1
    k1 c2:v2




                                            Hard drive
A write’s journal
write(    k2   ,   c1:v1 c2:v2   )

                                                        Memory
                                     k1 c1:v1 c2:v2

                                     k2 c1:v1 c2:v2




   k1 c1:v1
   k1 c2:v2
 k2 c1:v1 c2:v2




                                                      Hard drive
A write’s journal
write(    k1   ,   c1:v4 c3:v3   )

                                                              Memory
                                     k1 c1:v4 c2:v2 c3:v3

                                     k2 c1:v1 c2:v2




   k1 c1:v1
   k1 c2:v2
 k2 c1:v1 c2:v2
k1 c1:v4 c3:v3




                                                            Hard drive
A write’s journal
                                              Memory




          flush




                 index
cleanup    k1 c1:v4 c2:v2 c3:v3

           k2 c1:v1 c2:v2


                                  SSTable




                                            Hard drive
A write’s journal
more updates

                                                             Memory
                                          k1 c1:v5 c4:v4

                                          k2 c1:v2 c3:v3




 k2 c1:v2 c3:v3
 k1 c1:v5 c4:v4
                         index
                   k1 c1:v4 c2:v2 c3:v3

                   k2 c1:v1 c2:v2




                                                           Hard drive
A write’s journal
                                              Memory




                        flush


       index                     index
 k1 c1:v4 c2:v2 c3:v3      k1 c1:v5 c4:v4

 k2 c1:v1 c2:v2            k2 c1:v2 c3:v3




                                            Hard drive
Writes properties


• No reads or seeks
• Only sequential I/O
• Immutable SSTables: easy snapshots
A read’s journal
read( k1 )
                                                       Memory
    ?




                   index                  index
             k1 c1:v4 c2:v2 c3:v3   k1 c1:v5 c4:v4

             k2 c1:v1 c2:v2         k2 c1:v2 c3:v3




                                                     Hard drive
A read’s journal
k1 c1:v5 c2:v2 c3:v3 c4:v4


                                                                 Memory

merge




                             index                  index
                       k1 c1:v4 c2:v2 c3:v3   k1 c1:v5 c4:v4

                       k2 c1:v1 c2:v2         k2 c1:v2 c3:v3




                                                               Hard drive
Compaction

• Goal: keep the number of SSTables low
• Merge sort against multiple sstables
• Sequential I/O
Compaction

• Goal: keep the number of SSTables low
• Merge sort against multiple sstables
• Sequential I/O
          index
    k1 c1:v4 c2:v2 c3:v3

    k2 c1:v1 c2:v2



          index
    k1 c1:v5 c4:v4

    k2 c1:v2 c3:v3
Compaction

• Goal: keep the number of SSTables low
• Merge sort against multiple sstables
• Sequential I/O
          index
    k1 c1:v4 c2:v2 c3:v3

    k2 c1:v1 c2:v2
                                      index
                                k1 c1:v5 c2:v2 c3:v3 c4:v4
          index                 k2 c1:v2 c2:v2 c3:v3

    k1 c1:v5 c4:v4

    k2 c1:v2 c3:v3
Optimizations

• Row Cache
• Bloom filters: eliminates whole SSTable
• Key Cache
• Rows & Columns Indexes
• ...
Other features

• Compression
• Checksums
• Time to live
Questions?
• Cassandra 1.1 scheduled for next month
• http://cassandra.apache.org/
• http://wiki.apache.org/cassandra/
• http://www.datastax.com/docs/1.0
Data Model
                     Keyspace name

                 Column Family name

                           Row key

                      Column name

                              Value
                    Columns (upto 2B)
          Rows (∞)
     Column Families (10’s ➝ 100’s)
Keyspaces (1 per app)
Leveled Compaction

L0


L1


L2


L3
Leveled Compaction

L0


L1


L2


L3
Leveled Compaction

L0


L1


L2


L3
Leveled Compaction

L0


L1


L2


L3
Leveled Compaction

L0


L1


L2


L3
Leveled Compaction

L0


L1


L2


L3

More Related Content

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

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
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
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 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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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...
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Fosdem 2012

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n