SlideShare a Scribd company logo
1 of 26
Download to read offline
Overview of
Cassandra
Outline
● History/motivation
● Semi structured data in Cassandra
  ○ CFs and SuperCFs
● Architecture of Cassandra system
  ○   Distribution of content
  ○   Replication of content
  ○   Consistency level
  ○   Node internals
  ○   Gossip
● Thrift API
● Design patterns - denormalization
History/motivation
● Initially developed by facebook for Inbox
  Search
  ○ in late 2007/early 2008
● Designed for
  ○ node failure - commodity hardware
  ○ scale - can increase number of nodes easily to
    accommodate increasing demand
  ○ fast write access while delivering good read
    performance
● Combination of Bigtable and Dynamo
● Was operational for over 2 years
  ○ Dropped in favour of HBase
History/motivation
● Released as open source in July 2008
● Apache liked it
  ○ Became Apache Incubator project in March 2009
  ○ Became Apache top level project in Feb 2010
● Active project with releases every few
  months
  ○ currently on version 1.1
    ■ production ready, but still evolving
Why it's interesting (in this
context)...
● Has seen significant growth in last couple of
  years
● Enough deployments to be credible
   ○ Netflix, Ooyala, Digg, Cisco,
● Is scalable and robust enough for big data
  problems
   ○ no single point of failure
● Complex system
   ○ perhaps excessively complex today
Cassandra - semi
structured data
● Column based database
  ○ has similarities to standard RDBMS
● Terminology:
  ○ Keystore -> database
  ○ ColumnFamily -> table
Cassandra - semi
structured data
● No specific schema is required
  ○ although it is possible to define schema
    ■ can include typing information for parts of
        schema to minimize data integrity problems
● Rows can have large numbers of columns
  ○ limit on number of columns is 2B
● Column values should not exceed some MB
● SuperColumns are columns embedded
  within columns
  ○ third level in a map
  ○ little discussion of SC here
Supercolumns depicted
Cassandra - secondary
indexing
● Columns can be indexed
  ○ so-called 'secondary indexing'
    ■ row keys form the primary index
● Some debate abt the merits of secondary
  indexing in cassandra
  ○ secondary indexing is an atomic operation
    ■ unlike alternative 'manual' indexing approach
  ○ causes change in thinking regarding NoSQL design
    ■ very similar to classical RDBMS thinking
Cassandra Architecture
● Cluster configuration typical
● All nodes peers
   ○ although there are some seeds which should be
     more reliable, larger nodes
● Peers have common view of tokenspace
   ○ tokenspace is a ring
      ■ of size 2^127
   ○ peers have responsibility for some part of ring
      ■ ie some range of tokens within ring
● Row key/keyspace mapped to token
   ○ used to determine which node is responsible for row
     data
Cassandra - Cluster and
Tokenspace
Cassandra - Data
Distribution
● Map from RowKey to token determines data
  distribution
● RandomPartitioner is most important map
  ○   generates MD5 hash of rowkey
  ○   distributes data evenly over nodes in cluster
  ○   highly preferred solution
  ○   constraint that it is not possible to iterate over rows
● OrderedPartitioner
  ○ generates token based on simply byte mapping of
    row key
  ○ most probably results in uneven distribution of data
  ○ can be used to iterate over rows
Cassandra - Data
Replication
● Multiple levels of replication supported
   ○ can support arbitrary level of replication
   ○ replication factors specified per keyspace
● Two replication strategies
   ○ RackUnaware
     ■ Make replicas in next n nodes along token ring
   ○ RackAware
     ■ Makes one replica in remote data centre
     ■ Make remaining replicas in next nodes along
       token ring
          ●   good ring configuration should result in diversity over data
              centres
Cassandra - Consistency
Level
● A mechanism to trade off latency with data
  consistency
  ○ Write case:
    ■ Faster response <-> less sure data written
       properly
  ○ Read case:
    ■ Faster response <-> less sure most recent data
       read
● Related to data replication above
  ○ replication factor determines meaningful levels for
    consistency level
Cassandra - Consistency
  Level - Write
Level     Behavior
ANY       Ensure that the write has been written to at least 1 node, including HintedHandoff recipients.
ONE       Ensure that the write has been written to at least 1 replica's commit log and memory table
          before responding to the client.
TWO       Ensure that the write has been written to at least 2 replica's before responding to the client.
THREE     Ensure that the write has been written to at least 3 replica's before responding to the client.
QUORUM    Ensure that the write has been written to N / 2 + 1 replicas before responding to the client.
LOCAL_Q   Ensure that the write has been written to <ReplicationFactor> / 2 + 1 nodes, within the local
UORUM     datacenter (requires NetworkTopologyStrategy)
EACH_QU   Ensure that the write has been written to <ReplicationFactor> / 2 + 1 nodes in each datacenter
ORUM      (requires NetworkTopologyStrategy)
ALL       Ensure that the write is written to all N replicas before responding to the client. Any
          unresponsive replicas will fail the operation.
Cassandra - Consistency
  Level - Read
Level     Behavior
ANY       Not supported. You probably want ONE instead.
ONE       Will return the record returned by the first replica to respond. A consistency check is always
          done in a background thread to fix any consistency issues when ConsistencyLevel.ONE is
          used. This means subsequent calls will have correct data even if the initial read gets an older
          value. (This is calledReadRepair)
TWO       Will query 2 replicas and return the record with the most recent timestamp. Again, the
          remaining replicas will be checked in the background.
THREE     Will query 3 replicas and return the record with the most recent timestamp.
QUORUM    Will query all replicas and return the record with the most recent timestamp once it has at least
          a majority of replicas (N / 2 + 1) reported. Again, the remaining replicas will be checked in the
          background.
LOCAL_Q   Returns the record with the most recent timestamp once a majority of replicas within the local
UORUM     datacenter have replied.
EACH_QU   Returns the record with the most recent timestamp once a majority of replicas within each
ORUM      datacenter have replied.
ALL       Will query all replicas and return the record with the most recent timestamp once all replicas
          have replied. Any unresponsive replicas will fail the operation.
Cassandra - Node Internals
● Node comprises
  ○ commit log
    ■ list of pending writes
  ○ memtable
    ■ data written to system resident in memory
  ○ SSTables
    ■ per CF file containing persistent data
● Memtable writes when out of space, too
  many keys or after time period
● SSTables comprise of
  ○ Data - sorted strings
  ○ Index, Bloom Filter
Cassandra - Node Internals
● Compaction occurs from time to time
  ○ cleans up SSTable
  ○ removes redundant rows
  ○ regenerates indexes
Cassandra - Behaviour -
Write
● Write properties:
  ○   No reads
  ○   No seeks
  ○   Fast!
  ○   Atomic within CF
  ○   Always writable
Cassandra - Behaviour -
Read
● Read Path:
  ○   Any node
  ○   Partitioner
  ○   Wait for R responses
  ○   Wait for N-R responses in background and perform
      read repair
● Read Properties:
  ○   Read multiple SSTables
  ○   Slower than writes (but stil fast)
  ○   Seeks can be mitigated with more RAM
  ○   Scales to billions of rows
Cassandra - Gossip
● Gossip protocol used to relay information
  between nodes in cluster
● Proactive communications mechanism to
  share information
  ○ nodes proactively share what they know with
    random other nodes
● Token space information exchanged via
  gossip
● Failure detection based on gossip
  ○ heartbeat mechanism
Thrift API - basic calls
● insert(key, column_parent, column,
    consistency_level)
    ○ key is row/keyspace identifier
    ○ column_parent is either column identifier
       ■ can be column name or super column idenfier
    ○ column is column data
●   get(key, column_path, consistency_level)
    ○ returns a column corresponding to the key
●   get_slice(key, column_parent,
    slice_predicate, consistency_level)
    ○ typically returns set of columns corresponding to key
Thrift API - other
operations
● get multiple rows
● delete row
● batch operations
  ○ important for speeding up system
  ○ can batch up mix of add, insert and delete
    operations
● keyspace and cluster management
Denormalization
● Cassandra requires query oriented design
  ○ determine queries first, design data models
    accordingly
  ○ in contrast to standard RDBMS
     ■ normalize data at design time
     ■ construct arbitrary queries usually based on joins
● Quite fundamental difference in approach
  ○ typically results in quite different data models
● Common use of valueless columns
  ○ column name contains data
    ■ good for time series data
  ○ can have very many columns in given row
Denormalization
● Standard SQL
   ○ SELECT * FROM USER WHERE CITY = 'Dublin'
● Typically create CF which groups users by
  city
   ○ row key is city identifer
   ○ columns are user IDs
● Can get UID of all users in given city by
  querying this CF
   ○ give city as row-key
Other considerations...
● SuperColumnFamily
  ○ when it is useful?
● Multi data centre deployments
  ○ Cassandra can leverage topology to maximize
    resiliency
● Reaction to node failure
● Reconfiguration of system
  ○ introduction of new nodes into existing system


● It is a complex system with many working
  parts

More Related Content

What's hot

NOSQL Database: Apache Cassandra
NOSQL Database: Apache CassandraNOSQL Database: Apache Cassandra
NOSQL Database: Apache CassandraFolio3 Software
 
Appache Cassandra
Appache Cassandra  Appache Cassandra
Appache Cassandra nehabsairam
 
Cassandra - A decentralized storage system
Cassandra - A decentralized storage systemCassandra - A decentralized storage system
Cassandra - A decentralized storage systemArunit Gupta
 
Building and running cloud native cassandra
Building and running cloud native cassandraBuilding and running cloud native cassandra
Building and running cloud native cassandraVinay Kumar Chella
 
Introduction to Cassandra: Replication and Consistency
Introduction to Cassandra: Replication and ConsistencyIntroduction to Cassandra: Replication and Consistency
Introduction to Cassandra: Replication and ConsistencyBenjamin Black
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to CassandraGokhan Atil
 
Scylla Summit 2022: Making Schema Changes Safe with Raft
Scylla Summit 2022: Making Schema Changes Safe with RaftScylla Summit 2022: Making Schema Changes Safe with Raft
Scylla Summit 2022: Making Schema Changes Safe with RaftScyllaDB
 
Understanding Data Partitioning and Replication in Apache Cassandra
Understanding Data Partitioning and Replication in Apache CassandraUnderstanding Data Partitioning and Replication in Apache Cassandra
Understanding Data Partitioning and Replication in Apache CassandraDataStax
 
Introduction to cassandra
Introduction to cassandraIntroduction to cassandra
Introduction to cassandraNguyen Quang
 
Apache Cassandra Multi-Datacenter Essentials (Julien Anguenot, iLand Internet...
Apache Cassandra Multi-Datacenter Essentials (Julien Anguenot, iLand Internet...Apache Cassandra Multi-Datacenter Essentials (Julien Anguenot, iLand Internet...
Apache Cassandra Multi-Datacenter Essentials (Julien Anguenot, iLand Internet...DataStax
 
Introduction to Cassandra Basics
Introduction to Cassandra BasicsIntroduction to Cassandra Basics
Introduction to Cassandra Basicsnickmbailey
 
MariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationMariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationFrancisco Gonçalves
 
Presentation of Apache Cassandra
Presentation of Apache Cassandra Presentation of Apache Cassandra
Presentation of Apache Cassandra Nikiforos Botis
 
Bulk Loading into Cassandra
Bulk Loading into CassandraBulk Loading into Cassandra
Bulk Loading into CassandraBrian Hess
 
Materialized Views and Secondary Indexes in Scylla: They Are finally here!
Materialized Views and Secondary Indexes in Scylla: They Are finally here!Materialized Views and Secondary Indexes in Scylla: They Are finally here!
Materialized Views and Secondary Indexes in Scylla: They Are finally here!ScyllaDB
 

What's hot (20)

NOSQL Database: Apache Cassandra
NOSQL Database: Apache CassandraNOSQL Database: Apache Cassandra
NOSQL Database: Apache Cassandra
 
Appache Cassandra
Appache Cassandra  Appache Cassandra
Appache Cassandra
 
Cassandra - A decentralized storage system
Cassandra - A decentralized storage systemCassandra - A decentralized storage system
Cassandra - A decentralized storage system
 
Building and running cloud native cassandra
Building and running cloud native cassandraBuilding and running cloud native cassandra
Building and running cloud native cassandra
 
Introduction to Cassandra: Replication and Consistency
Introduction to Cassandra: Replication and ConsistencyIntroduction to Cassandra: Replication and Consistency
Introduction to Cassandra: Replication and Consistency
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to Cassandra
 
Scylla Summit 2022: Making Schema Changes Safe with Raft
Scylla Summit 2022: Making Schema Changes Safe with RaftScylla Summit 2022: Making Schema Changes Safe with Raft
Scylla Summit 2022: Making Schema Changes Safe with Raft
 
Cassandra
CassandraCassandra
Cassandra
 
Understanding Data Partitioning and Replication in Apache Cassandra
Understanding Data Partitioning and Replication in Apache CassandraUnderstanding Data Partitioning and Replication in Apache Cassandra
Understanding Data Partitioning and Replication in Apache Cassandra
 
Introduction to cassandra
Introduction to cassandraIntroduction to cassandra
Introduction to cassandra
 
Apache Cassandra Multi-Datacenter Essentials (Julien Anguenot, iLand Internet...
Apache Cassandra Multi-Datacenter Essentials (Julien Anguenot, iLand Internet...Apache Cassandra Multi-Datacenter Essentials (Julien Anguenot, iLand Internet...
Apache Cassandra Multi-Datacenter Essentials (Julien Anguenot, iLand Internet...
 
Introduction to Cassandra Basics
Introduction to Cassandra BasicsIntroduction to Cassandra Basics
Introduction to Cassandra Basics
 
MariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationMariaDB Galera Cluster presentation
MariaDB Galera Cluster presentation
 
Cassandra 101
Cassandra 101Cassandra 101
Cassandra 101
 
NoSQL databases
NoSQL databasesNoSQL databases
NoSQL databases
 
Presentation of Apache Cassandra
Presentation of Apache Cassandra Presentation of Apache Cassandra
Presentation of Apache Cassandra
 
Bulk Loading into Cassandra
Bulk Loading into CassandraBulk Loading into Cassandra
Bulk Loading into Cassandra
 
Materialized Views and Secondary Indexes in Scylla: They Are finally here!
Materialized Views and Secondary Indexes in Scylla: They Are finally here!Materialized Views and Secondary Indexes in Scylla: They Are finally here!
Materialized Views and Secondary Indexes in Scylla: They Are finally here!
 
Spark architecture
Spark architectureSpark architecture
Spark architecture
 
Cassandra Database
Cassandra DatabaseCassandra Database
Cassandra Database
 

Similar to Cassandra overview

An Introduction to Apache Cassandra
An Introduction to Apache CassandraAn Introduction to Apache Cassandra
An Introduction to Apache CassandraSaeid Zebardast
 
On Rails with Apache Cassandra
On Rails with Apache CassandraOn Rails with Apache Cassandra
On Rails with Apache CassandraStu Hood
 
Apache cassandra an introduction
Apache cassandra  an introductionApache cassandra  an introduction
Apache cassandra an introductionShehaaz Saif
 
Talk about apache cassandra, TWJUG 2011
Talk about apache cassandra, TWJUG 2011Talk about apache cassandra, TWJUG 2011
Talk about apache cassandra, TWJUG 2011Boris Yen
 
Talk About Apache Cassandra
Talk About Apache CassandraTalk About Apache Cassandra
Talk About Apache CassandraJacky Chu
 
Cassandra for mission critical data
Cassandra for mission critical dataCassandra for mission critical data
Cassandra for mission critical dataOleksandr Semenov
 
Cassandra Talk: Austin JUG
Cassandra Talk: Austin JUGCassandra Talk: Austin JUG
Cassandra Talk: Austin JUGStu Hood
 
The Hows and Whys of a Distributed SQL Database - Strange Loop 2017
The Hows and Whys of a Distributed SQL Database - Strange Loop 2017The Hows and Whys of a Distributed SQL Database - Strange Loop 2017
The Hows and Whys of a Distributed SQL Database - Strange Loop 2017Alex Robinson
 
How Optimizely (Safely) Maximizes Database Concurrency.pdf
How Optimizely (Safely) Maximizes Database Concurrency.pdfHow Optimizely (Safely) Maximizes Database Concurrency.pdf
How Optimizely (Safely) Maximizes Database Concurrency.pdfScyllaDB
 
Cassandra sharding and consistency (lightning talk)
Cassandra sharding and consistency (lightning talk)Cassandra sharding and consistency (lightning talk)
Cassandra sharding and consistency (lightning talk)Federico Razzoli
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to Cassandrashimi_k
 
Online Analytics with Hadoop and Cassandra
Online Analytics with Hadoop and CassandraOnline Analytics with Hadoop and Cassandra
Online Analytics with Hadoop and CassandraRobbie Strickland
 
Data Policies for the Kafka-API with WebAssembly | Alexander Gallego, Vectorized
Data Policies for the Kafka-API with WebAssembly | Alexander Gallego, VectorizedData Policies for the Kafka-API with WebAssembly | Alexander Gallego, Vectorized
Data Policies for the Kafka-API with WebAssembly | Alexander Gallego, VectorizedHostedbyConfluent
 
Dynamo cassandra
Dynamo cassandraDynamo cassandra
Dynamo cassandraWu Liang
 

Similar to Cassandra overview (20)

An Introduction to Apache Cassandra
An Introduction to Apache CassandraAn Introduction to Apache Cassandra
An Introduction to Apache Cassandra
 
Cassandra
CassandraCassandra
Cassandra
 
On Rails with Apache Cassandra
On Rails with Apache CassandraOn Rails with Apache Cassandra
On Rails with Apache Cassandra
 
Apache cassandra an introduction
Apache cassandra  an introductionApache cassandra  an introduction
Apache cassandra an introduction
 
Talk about apache cassandra, TWJUG 2011
Talk about apache cassandra, TWJUG 2011Talk about apache cassandra, TWJUG 2011
Talk about apache cassandra, TWJUG 2011
 
Talk About Apache Cassandra
Talk About Apache CassandraTalk About Apache Cassandra
Talk About Apache Cassandra
 
Cassandra training
Cassandra trainingCassandra training
Cassandra training
 
Cassandra
CassandraCassandra
Cassandra
 
Cassandra for mission critical data
Cassandra for mission critical dataCassandra for mission critical data
Cassandra for mission critical data
 
Cassandra Talk: Austin JUG
Cassandra Talk: Austin JUGCassandra Talk: Austin JUG
Cassandra Talk: Austin JUG
 
The Hows and Whys of a Distributed SQL Database - Strange Loop 2017
The Hows and Whys of a Distributed SQL Database - Strange Loop 2017The Hows and Whys of a Distributed SQL Database - Strange Loop 2017
The Hows and Whys of a Distributed SQL Database - Strange Loop 2017
 
Intro to cassandra
Intro to cassandraIntro to cassandra
Intro to cassandra
 
How Optimizely (Safely) Maximizes Database Concurrency.pdf
How Optimizely (Safely) Maximizes Database Concurrency.pdfHow Optimizely (Safely) Maximizes Database Concurrency.pdf
How Optimizely (Safely) Maximizes Database Concurrency.pdf
 
Cassandra sharding and consistency (lightning talk)
Cassandra sharding and consistency (lightning talk)Cassandra sharding and consistency (lightning talk)
Cassandra sharding and consistency (lightning talk)
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to Cassandra
 
Cassandra1.2
Cassandra1.2Cassandra1.2
Cassandra1.2
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
 
Online Analytics with Hadoop and Cassandra
Online Analytics with Hadoop and CassandraOnline Analytics with Hadoop and Cassandra
Online Analytics with Hadoop and Cassandra
 
Data Policies for the Kafka-API with WebAssembly | Alexander Gallego, Vectorized
Data Policies for the Kafka-API with WebAssembly | Alexander Gallego, VectorizedData Policies for the Kafka-API with WebAssembly | Alexander Gallego, Vectorized
Data Policies for the Kafka-API with WebAssembly | Alexander Gallego, Vectorized
 
Dynamo cassandra
Dynamo cassandraDynamo cassandra
Dynamo cassandra
 

More from Sean Murphy

More from Sean Murphy (8)

Hadoop pig
Hadoop pigHadoop pig
Hadoop pig
 
Demonstration
DemonstrationDemonstration
Demonstration
 
Overview of no sql
Overview of no sqlOverview of no sql
Overview of no sql
 
No sql course introduction
No sql course   introductionNo sql course   introduction
No sql course introduction
 
Rss talk
Rss talkRss talk
Rss talk
 
Rss announcements
Rss announcementsRss announcements
Rss announcements
 
Rocco pres-v1
Rocco pres-v1Rocco pres-v1
Rocco pres-v1
 
UCD Android Workshop
UCD Android WorkshopUCD Android Workshop
UCD Android Workshop
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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 WorkerThousandEyes
 
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 organizationRadu Cotescu
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Cassandra overview

  • 2. Outline ● History/motivation ● Semi structured data in Cassandra ○ CFs and SuperCFs ● Architecture of Cassandra system ○ Distribution of content ○ Replication of content ○ Consistency level ○ Node internals ○ Gossip ● Thrift API ● Design patterns - denormalization
  • 3. History/motivation ● Initially developed by facebook for Inbox Search ○ in late 2007/early 2008 ● Designed for ○ node failure - commodity hardware ○ scale - can increase number of nodes easily to accommodate increasing demand ○ fast write access while delivering good read performance ● Combination of Bigtable and Dynamo ● Was operational for over 2 years ○ Dropped in favour of HBase
  • 4. History/motivation ● Released as open source in July 2008 ● Apache liked it ○ Became Apache Incubator project in March 2009 ○ Became Apache top level project in Feb 2010 ● Active project with releases every few months ○ currently on version 1.1 ■ production ready, but still evolving
  • 5. Why it's interesting (in this context)... ● Has seen significant growth in last couple of years ● Enough deployments to be credible ○ Netflix, Ooyala, Digg, Cisco, ● Is scalable and robust enough for big data problems ○ no single point of failure ● Complex system ○ perhaps excessively complex today
  • 6. Cassandra - semi structured data ● Column based database ○ has similarities to standard RDBMS ● Terminology: ○ Keystore -> database ○ ColumnFamily -> table
  • 7. Cassandra - semi structured data ● No specific schema is required ○ although it is possible to define schema ■ can include typing information for parts of schema to minimize data integrity problems ● Rows can have large numbers of columns ○ limit on number of columns is 2B ● Column values should not exceed some MB ● SuperColumns are columns embedded within columns ○ third level in a map ○ little discussion of SC here
  • 9. Cassandra - secondary indexing ● Columns can be indexed ○ so-called 'secondary indexing' ■ row keys form the primary index ● Some debate abt the merits of secondary indexing in cassandra ○ secondary indexing is an atomic operation ■ unlike alternative 'manual' indexing approach ○ causes change in thinking regarding NoSQL design ■ very similar to classical RDBMS thinking
  • 10. Cassandra Architecture ● Cluster configuration typical ● All nodes peers ○ although there are some seeds which should be more reliable, larger nodes ● Peers have common view of tokenspace ○ tokenspace is a ring ■ of size 2^127 ○ peers have responsibility for some part of ring ■ ie some range of tokens within ring ● Row key/keyspace mapped to token ○ used to determine which node is responsible for row data
  • 11. Cassandra - Cluster and Tokenspace
  • 12. Cassandra - Data Distribution ● Map from RowKey to token determines data distribution ● RandomPartitioner is most important map ○ generates MD5 hash of rowkey ○ distributes data evenly over nodes in cluster ○ highly preferred solution ○ constraint that it is not possible to iterate over rows ● OrderedPartitioner ○ generates token based on simply byte mapping of row key ○ most probably results in uneven distribution of data ○ can be used to iterate over rows
  • 13. Cassandra - Data Replication ● Multiple levels of replication supported ○ can support arbitrary level of replication ○ replication factors specified per keyspace ● Two replication strategies ○ RackUnaware ■ Make replicas in next n nodes along token ring ○ RackAware ■ Makes one replica in remote data centre ■ Make remaining replicas in next nodes along token ring ● good ring configuration should result in diversity over data centres
  • 14. Cassandra - Consistency Level ● A mechanism to trade off latency with data consistency ○ Write case: ■ Faster response <-> less sure data written properly ○ Read case: ■ Faster response <-> less sure most recent data read ● Related to data replication above ○ replication factor determines meaningful levels for consistency level
  • 15. Cassandra - Consistency Level - Write Level Behavior ANY Ensure that the write has been written to at least 1 node, including HintedHandoff recipients. ONE Ensure that the write has been written to at least 1 replica's commit log and memory table before responding to the client. TWO Ensure that the write has been written to at least 2 replica's before responding to the client. THREE Ensure that the write has been written to at least 3 replica's before responding to the client. QUORUM Ensure that the write has been written to N / 2 + 1 replicas before responding to the client. LOCAL_Q Ensure that the write has been written to <ReplicationFactor> / 2 + 1 nodes, within the local UORUM datacenter (requires NetworkTopologyStrategy) EACH_QU Ensure that the write has been written to <ReplicationFactor> / 2 + 1 nodes in each datacenter ORUM (requires NetworkTopologyStrategy) ALL Ensure that the write is written to all N replicas before responding to the client. Any unresponsive replicas will fail the operation.
  • 16. Cassandra - Consistency Level - Read Level Behavior ANY Not supported. You probably want ONE instead. ONE Will return the record returned by the first replica to respond. A consistency check is always done in a background thread to fix any consistency issues when ConsistencyLevel.ONE is used. This means subsequent calls will have correct data even if the initial read gets an older value. (This is calledReadRepair) TWO Will query 2 replicas and return the record with the most recent timestamp. Again, the remaining replicas will be checked in the background. THREE Will query 3 replicas and return the record with the most recent timestamp. QUORUM Will query all replicas and return the record with the most recent timestamp once it has at least a majority of replicas (N / 2 + 1) reported. Again, the remaining replicas will be checked in the background. LOCAL_Q Returns the record with the most recent timestamp once a majority of replicas within the local UORUM datacenter have replied. EACH_QU Returns the record with the most recent timestamp once a majority of replicas within each ORUM datacenter have replied. ALL Will query all replicas and return the record with the most recent timestamp once all replicas have replied. Any unresponsive replicas will fail the operation.
  • 17. Cassandra - Node Internals ● Node comprises ○ commit log ■ list of pending writes ○ memtable ■ data written to system resident in memory ○ SSTables ■ per CF file containing persistent data ● Memtable writes when out of space, too many keys or after time period ● SSTables comprise of ○ Data - sorted strings ○ Index, Bloom Filter
  • 18. Cassandra - Node Internals ● Compaction occurs from time to time ○ cleans up SSTable ○ removes redundant rows ○ regenerates indexes
  • 19. Cassandra - Behaviour - Write ● Write properties: ○ No reads ○ No seeks ○ Fast! ○ Atomic within CF ○ Always writable
  • 20. Cassandra - Behaviour - Read ● Read Path: ○ Any node ○ Partitioner ○ Wait for R responses ○ Wait for N-R responses in background and perform read repair ● Read Properties: ○ Read multiple SSTables ○ Slower than writes (but stil fast) ○ Seeks can be mitigated with more RAM ○ Scales to billions of rows
  • 21. Cassandra - Gossip ● Gossip protocol used to relay information between nodes in cluster ● Proactive communications mechanism to share information ○ nodes proactively share what they know with random other nodes ● Token space information exchanged via gossip ● Failure detection based on gossip ○ heartbeat mechanism
  • 22. Thrift API - basic calls ● insert(key, column_parent, column, consistency_level) ○ key is row/keyspace identifier ○ column_parent is either column identifier ■ can be column name or super column idenfier ○ column is column data ● get(key, column_path, consistency_level) ○ returns a column corresponding to the key ● get_slice(key, column_parent, slice_predicate, consistency_level) ○ typically returns set of columns corresponding to key
  • 23. Thrift API - other operations ● get multiple rows ● delete row ● batch operations ○ important for speeding up system ○ can batch up mix of add, insert and delete operations ● keyspace and cluster management
  • 24. Denormalization ● Cassandra requires query oriented design ○ determine queries first, design data models accordingly ○ in contrast to standard RDBMS ■ normalize data at design time ■ construct arbitrary queries usually based on joins ● Quite fundamental difference in approach ○ typically results in quite different data models ● Common use of valueless columns ○ column name contains data ■ good for time series data ○ can have very many columns in given row
  • 25. Denormalization ● Standard SQL ○ SELECT * FROM USER WHERE CITY = 'Dublin' ● Typically create CF which groups users by city ○ row key is city identifer ○ columns are user IDs ● Can get UID of all users in given city by querying this CF ○ give city as row-key
  • 26. Other considerations... ● SuperColumnFamily ○ when it is useful? ● Multi data centre deployments ○ Cassandra can leverage topology to maximize resiliency ● Reaction to node failure ● Reconfiguration of system ○ introduction of new nodes into existing system ● It is a complex system with many working parts