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

Recently uploaded (20)

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
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
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
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...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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
 
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...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 

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