SlideShare ist ein Scribd-Unternehmen logo
1 von 42
101
                for System Administrators



nathan@milford.io
twitter.com/NathanMilford
http://blog.milford.io
What is Cassandra?

• It is a distributed, columnar database.

• Originally created at Facebook in 2008, is now a top level
  Apache Project.

• Combines the best features of Amazon's Dynamo
  (replication, mostly) and Google's Big Table (data model).
Who uses
Cassandra?
Commercial
Support Available: 
zOMG BOOKS!
 @
Rocking ~30 Billion impressions a month, like a bawse.

Used for semi-persistent storage of recommendations.

•   14 nodes in two data centers.  
•   Dell R610, 8 cores, 32G of RAM, 6 x 10K SAS drives.
•   Using 0.8 currently, just upgraded. In production since 0.4.
•   We use Hector.
•   ~70-80G per node, ~550G dataset unreplicated.
•   RP + OldNTS @ RF2.  PropFileSnitch, RW @ CL.ONE.

  Excited for NTS

  Excited for TTLs!
How We Use Cassandra
   +--------------+ 
   |    Tomcat    |     Tomcat serves Recs from Memcached.
   +------------+-+ 
        ^       |
                        Flume ships logs to Hadoop DWH.
        |       | L    Bunch of algos run against log data.
  +-----+-----+ | O 
  | Memcached | | G     Results are crammed into Cassandra.
  +-----------+ | S
        ^       |
                        
                          Keyspace per algo.
        |       | V    CacheWarmer...
+-------+-----+ | I
| CacheWarmer | | A
                        
                          Sources recs from Cassandra (and other
+-------------+ |
        ^       | F
                          sources)
        |       | L     
                          Dumps them in Memcached.
  +-----+-----+ | U
  | Cassandra | | M
  +-----------+ | E
        ^       |
        |       v
   +----+--------+
   | Hadoop/Hive |
   +-------------+
* Simplified Workflow
Before I get too technical, relax.
The following slides may sound complex at first,  but at the
end of the day, to get your feet wet all you need to do is:


yum install / apt-get install
Define a Seed.
Define Strategies.
service cassandra start
Go get a beer.


In my experience, once the cluster has been setup there is
not much else to do other than occasional tuning as you
learn how your data behaves.
Why Cassandra?
• Minimal Administration.

• No Single Point of Failure.

• Scales Horizontally. 

• Writes are durable.

• Consistency is tuneable as needed on reads and writes.

• Schema is flexible, can be updated live.

• Handles failure gracefully, Cassandra is crash-only.

• Replication is easy, Rack and Datacenter aware.
Data Model
                          Keyspace = {
                            Column Family: {
                              Row Key: {
                                Column Name: "Column Value"
                                Column Name: "Column Value"
                              }
                            }
                          }

A Keyspace is a container for Column Families. Analogous to a
database in MySQL.

A Column Family is a container for a group of columns.  Analagous to
a table in MySQL.

A Column is the basic unit.  Key, Value and Timestamp.

A Row is a smattering of column data.
Gossip
         
             In config, define seed(s).  

         
             Used for intra-cluster
             communication. 

         
             Cluster self-assembles.

         
             Works with failure detection.

         
             Routes client requests.
Pluggable Partitioning

                           
                               RandomPartitioner (RP)

                               
                                   Orders by MD5 of the key.

                               
                                   Most common.

                               
                                   Distributes relatively evenly.




  There are others, but you probably will not use them.
Distributed Hash Table: The Ring
For Random Partitioner:

• Ring is made up of a range from
  0 to 2**127.

• Token is MD5(Key).

• Each node is given a slice of the
  ring
   o Initial token is defined,
     node owns that token up to
     the next node's initial token.


                     Rock your tokens here:
        http://blog.milford.io/cassandra-token-calculator/
Pluggable Topology Discovery
Cassandra needs to know about your network to direct
replica placement. Snitches inform Cassandra about it.
                  
                    SimpleSnitch 
                    
                      Default, good for 1 data center.
                  
                    RackInferringSnitch
                    
                      Infers location from the IP's octets.
                    
                      10.D.R.N (Data center, Rack, Node)
                  
                    PropertyFileSnitch
                    
                      cassandra-topology.properties
                    
                      IP=DC:RACK (arbitrary values)
                    
                      10.10.10.1=NY1:R1
                  
                    EC2Snitch
                    
                      Discovers AWS AZ and Regions.
Pluggable Replica Placement

    SimpleStratgy
    
      Places replicas in the adjacent nodes on the ring.


    NetworkTopologyStrategy
    
      Used with property file snitch.
    
      Explicitly pick how replicas are placed.
    
      strategy_options = [{NY1:2, LA1:2}];
Reading & Writing
Old method uses Thrift which is
usually abstracted using APIs
(ex. Hector, PyCassa, PHPCass)

Now we have CQL and JDBC!

SELECT * FROM ColumnFamily WHERE rowKey='Name';

Since all nodes are equal, you can read and write to any node.

The node you connect to becomes a Coordinator for that
request and routes your data to the proper nodes.

Connection pooling to nodes is sometimes handled by the API
Framework, otherwise use RRDNS or HAProxy.
Tunable Consistency
It is difficult to keep replicas of data consistant across nodes, let alone
across continents.

In any distributed system you have to make tradeoffs between how
consistent your dataset is versus how avaliable it is and how tolerant
the system is of partitions. (a.k.a CAP theorm.)

Cassandra chooses to focus on making the data avaliable and partition
tolerant and empower you to chose how consistant you need it to be.

Cassandra is awesomesauce because you choose what is more
important to your query, consistency or latency.
Per-Query Consistency Levels
Latency increases the more nodes you have to involve.

ANY:   For writes only. Writes to any avaliable node and expects
Cassandra to sort it out. Fire and forget.

ONE:   Reads or writes to the closest replica.

QUORUM:   Writes to half+1 of the appropriate replicas before the
operation is successful.  A read is sucessful when half+1 replicas agree
on a value to return.  

LOCAL_QUORUM:   Same as above, but only to the local datacenter in
a multi-datacenter topology.

ALL:   For writes, all replicas need to ack the write.  For reads, returns
the record with the newest timestamp once all replicas reply.  In both
cases, if we're missing even one replica, the operation fails.
Cassandra Write Path

  Cassandra identifies which node owns the token you're trying to
write based on your partitioning, replication and placement
strategies.


    Data Written to CommitLog
    
      Sequential writes to disk, kinda like a MySQL binlog.
    
      Mostly written to, is only read from upon a restart. 


    Data Written to Memtable.
    
      Acts as a Write-back cache of data.


 Memtable hits a threshold (configurable) it is flushed to disk as an
SSTable. An SSTable (Sorted String Table) is an immutable file on
disk. More on compaction later.
Cassandra Read Path

  Cassandra identifies which node owns the token you're trying to
read based on your partitioning, replication and placement
strategies.


    First checks the Bloom filter, which can save us some time.
    
      A space-efficient structure that tests if a key is on the node. 
    
      False positives are possible.
    
      False negatives are impossible.


    Then checks the index.
    
       Tells us which SStable file the data is in.
    
       And how far into the SStable file to look so we don't need to
      scan the whole thing.
Distributed Deletes

    Hard to delete stuff in a distributed system.
    
      Difficult to keep track of replicas.
    
      SSTables are immutable.


    Deleted items are tombstoned (marked for deletion).


    Data still exists, just can't be read by API.


    Cleaned out during major compaction, when SSTables are
    merged/remade.
Compaction
• When you have enough disparate SSTable files taking
  up space, they are merge sorted into single SSTable
  files.

• An expensive process (lots of GC, can eat up half of your
  disk space)

• Tombstones discarded.

• Manual or automatic.

• Pluggable in 1.0.

• Leveled Compaction in 1.0
Repair

    Anti-Entropy and Read Repair
    
      During node repair and QUORUM & ALL reads,
      ColumnFamilies are compared with replicas and
      discrepancies resolved.

    
        Put manual repair in cron to run at an interval =< the
        value of GCGraceSeconds to catch old tombstones or
        risk forgotten deletes.


    Hinted Handoff
    
      If a node is down, writes spool on other nodes and are
      handed off then it comes back.

    
        Sometimes left off, since a returning node can get
        flooded.
Caching
 
     Key Cache
     
       Puts the location of keys in memory.
     
       Improves seek times for keys on disk.
     
       Enabled per ColumnFamily.
     
       On by default at 200,000 keys.

 
     Row Cache
     
       Keeps full rows of hot data in memory.
     
       Enable per ColumnFamily.
     
       Skinny rows are more efficient.

Row Cache is consulted first,
then the Key Cache

Will require a bit of tuning.
Hardware

RAM: Depends on use. Stores some
  objects off Heap.

CPU: More cores the better.  
  Cassandra is built with concurrency in mind.

Disk: Cassandra tries to minimize random IO.  Minimum of 2   
  disks.  Keep CommitLog and Data on separate spindles.  
  RAID10 or RAID0 as you see fit.  I set mine up thus:

     1 Disk = OS + Commitlog & RAID10 = DataSSTables

Network:  1 x 1gigE is fine, more the better and Gossip and 
  Data can be defined on separate interfaces.
What about 'Cloud' environments?

EC2Snitch
 • Maps EC2 Regions to Racks
 • Maps EC2 Availability Zones to DCs
 • Use Network Topology Strategy



Avoid EBS. Use RAID0/RAID10 across ephemeral drives.
Replicate across Availability Zones.

Netflix is moving to 100% Cassandra on EC2:
http://www.slideshare.net/adrianco/migrating-netflix-from-
oracle-to-global-cassandra 
Installing
RedHat
rpm -i http://rpm.datastax.com/EL/6/x86_64/riptano-release-5-1.el6.noarch.rpm
yum -y install apache-cassandra




Debian 
Add to /etc/apt/sources.list
deb http://www.apache.org/dist/cassandra/debian unstable main
deb-src http://www.apache.org/dist/cassandra/debian unstable main

wget http://www.apache.org/dist/cassandra/KEYS -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install cassandra
Config and Log Files


                       
                           /etc/cassandra/conf/
                           
                             cassandra.yaml
                           
                             cassandra-env.sh

                       
                           /var/log/cassandra/
                           
                             cassandra.log
                           
                             system.log
                           
                             gc.log (If Enabled.)
Hot Tips
• Use Sun/Oracle JVM (1.6 u22+)

• Use JNA Library.
  o Keep disk_access_mode as auto.
  o BTW, it is not using all your RAM, is like FS Cache.


• Don't use autobootstrap, specify initial token.

• Super columns impose a performance penalty.

• Enable GC logging in cassandra-env.sh 

• Don't use a large heap. (Yay off-heap caching!)

• Don't use swap.
Monitoring




     Install MX4J jar into class path or ping JMX directly.

curl | grep | awk it into Nagios, Ganglia, Cacti or what have you.
What to Monitor

  Heap Size and Usage         
                                CompactionStage

  Garbage Collections         
                                Compaction Count

  IO Wait                     
                                Cache Hit Rate

  RowMutationStage (Writes)   
                                ReadStage
  
    Active and Pending          
                                  Active and Pending
Adding/Removing/Replacing Nodes

    Adding a Node
    
      Calculate new tokens.
    
      Set correct initial token on the new node
    
      Once it bootstrapped, nodetool move on other nodes.


    Removing a Node
    
      nodetool decommission drains data to other nodes
    
      nodetool removetoken tells the cluster to get the
      data from other replicas (faster, more expensive on live
      nodes).


    Replacing a Node
    
      Bring up replacement node with same IP and token.
    
      Run nodetool repair. 
Useful nodetool commands.
nodetool info - Displays node-level info.

nodetool ring - Displays info on nodes on the ring.

nodetool cfstats - Displays ColumnFamily statistics.

nodetool tpstats - Displays what operations Cassandra
is doing right now.

nodetool netstats - Displays streaming information.

nodetool drain - Flushes Memtables to SSTables on disk
and stops accepting writes.  Useful before a restart to make
startup quicker (no CommitLog to replay)
nodetool info
nodetool ring
nodetool tpstats
nodetool cfstats
nodetool cfhistograms
Backups
 
     Single Node Snapshot
     
       nodetool snapshot 
     
       nodetool clearsnapshot
     
       Makes a hardlink of SSTables that you can tarball.

 
     Cluster-wide Snapshot.
     
       clustertool global_snapshot
     
       clustertool clear_global_snapshot
     
       Just does local snapshots on all nodes.

 
     To restore:
     
       Stop the node.
     
       Clear CommitLogs.
     
       Zap *.db files in the Keyspace directory.
     
       Copy the snapshot over from the snapshots subdirectory.
     
       Start the node and wait for load to decrease.
Shutdown Best Practice
While Cassandra is crash-safe, you can make a cleaner
shutdown and save some time during startup thus:


    Make other nodes think this one is down.
    
        nodetool -h $(hostname) -p 8080 disablegossip


    Wait a few secs, cut off anyone from writing to this node.
    
        nodetool -h $(hostname) -p 8080 dissablethrift


    Flush all memtables to disk.
    
        nodetool -h $(hostname) -p 8080 drain


    Shut it down.
    
        /etc/init.d/cassandra stop
Rolling Upgrades
From 0.7 you can do rolling upgrades. Check for cassandra.yaml changes!


    On each node, one by one:
    
        Shutdown as in previous slide, but do a snapshot after draining.
    
        Remove old jars, rpms, debs. Your data will not be touched.
    
        Add new jars, rpms, debs.
    
        /etc/init.d/cassandra start
    
        Wait for the node to come back up and for the other nodes to see it.

    When done, before you run repair, on each node run:
    
        nodetool -h $(hostname) -p 8080 scrub
    
        This is rebuilding the sstables to make them up to date.
    
        It is essentially a major compaction, without compacting, so it is a bit
        expensive.

    Run repair on your nodes to clean up the data.
    
        nodetool -h $(hostname) -p 8080 repair
Join Us!

   http://www.meetup.com/NYC-Cassandra-User-Group/




               We'll be          ing You!




              These slides can be found here:
http://www.slideshare.net/nmilford/cassandra-for-sysadmins

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Real-Time Analytics with Cassandra and Hadoop
Introduction to Real-Time Analytics with Cassandra and HadoopIntroduction to Real-Time Analytics with Cassandra and Hadoop
Introduction to Real-Time Analytics with Cassandra and HadoopPatricia Gorla
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to CassandraGokhan Atil
 
Everyday I’m scaling... Cassandra
Everyday I’m scaling... CassandraEveryday I’m scaling... Cassandra
Everyday I’m scaling... CassandraInstaclustr
 
Introduction to NoSQL & Apache Cassandra
Introduction to NoSQL & Apache CassandraIntroduction to NoSQL & Apache Cassandra
Introduction to NoSQL & Apache CassandraChetan Baheti
 
An Overview of Apache Cassandra
An Overview of Apache CassandraAn Overview of Apache Cassandra
An Overview of Apache CassandraDataStax
 
Understanding AntiEntropy in Cassandra
Understanding AntiEntropy in CassandraUnderstanding AntiEntropy in Cassandra
Understanding AntiEntropy in CassandraJason Brown
 
Introduction to Apache Cassandra
Introduction to Apache CassandraIntroduction to Apache Cassandra
Introduction to Apache CassandraRobert Stupp
 
Intro to cassandra
Intro to cassandraIntro to cassandra
Intro to cassandraAaron Ploetz
 
Large partition in Cassandra
Large partition in CassandraLarge partition in Cassandra
Large partition in CassandraShogo Hoshii
 
Apache Cassandra at the Geek2Geek Berlin
Apache Cassandra at the Geek2Geek BerlinApache Cassandra at the Geek2Geek Berlin
Apache Cassandra at the Geek2Geek BerlinChristian Johannsen
 
Apache Cassandra 2.0
Apache Cassandra 2.0Apache Cassandra 2.0
Apache Cassandra 2.0Joe Stein
 
Bulk Loading Data into Cassandra
Bulk Loading Data into CassandraBulk Loading Data into Cassandra
Bulk Loading Data into CassandraDataStax
 
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016DataStax
 
Monitoring Cassandra at Scale (Jason Cacciatore, Netflix) | C* Summit 2016
Monitoring Cassandra at Scale (Jason Cacciatore, Netflix) | C* Summit 2016Monitoring Cassandra at Scale (Jason Cacciatore, Netflix) | C* Summit 2016
Monitoring Cassandra at Scale (Jason Cacciatore, Netflix) | C* Summit 2016DataStax
 
Cassandra concepts, patterns and anti-patterns
Cassandra concepts, patterns and anti-patternsCassandra concepts, patterns and anti-patterns
Cassandra concepts, patterns and anti-patternsDave Gardner
 
Cassandra Explained
Cassandra ExplainedCassandra Explained
Cassandra ExplainedEric Evans
 
Understanding Data Consistency in Apache Cassandra
Understanding Data Consistency in Apache CassandraUnderstanding Data Consistency in Apache Cassandra
Understanding Data Consistency in Apache CassandraDataStax
 
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...DataStax
 
One Billion Black Friday Shoppers on a Distributed Data Store (Fahd Siddiqui,...
One Billion Black Friday Shoppers on a Distributed Data Store (Fahd Siddiqui,...One Billion Black Friday Shoppers on a Distributed Data Store (Fahd Siddiqui,...
One Billion Black Friday Shoppers on a Distributed Data Store (Fahd Siddiqui,...DataStax
 
Apache Cassandra multi-datacenter essentials
Apache Cassandra multi-datacenter essentialsApache Cassandra multi-datacenter essentials
Apache Cassandra multi-datacenter essentialsJulien Anguenot
 

Was ist angesagt? (20)

Introduction to Real-Time Analytics with Cassandra and Hadoop
Introduction to Real-Time Analytics with Cassandra and HadoopIntroduction to Real-Time Analytics with Cassandra and Hadoop
Introduction to Real-Time Analytics with Cassandra and Hadoop
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to Cassandra
 
Everyday I’m scaling... Cassandra
Everyday I’m scaling... CassandraEveryday I’m scaling... Cassandra
Everyday I’m scaling... Cassandra
 
Introduction to NoSQL & Apache Cassandra
Introduction to NoSQL & Apache CassandraIntroduction to NoSQL & Apache Cassandra
Introduction to NoSQL & Apache Cassandra
 
An Overview of Apache Cassandra
An Overview of Apache CassandraAn Overview of Apache Cassandra
An Overview of Apache Cassandra
 
Understanding AntiEntropy in Cassandra
Understanding AntiEntropy in CassandraUnderstanding AntiEntropy in Cassandra
Understanding AntiEntropy in Cassandra
 
Introduction to Apache Cassandra
Introduction to Apache CassandraIntroduction to Apache Cassandra
Introduction to Apache Cassandra
 
Intro to cassandra
Intro to cassandraIntro to cassandra
Intro to cassandra
 
Large partition in Cassandra
Large partition in CassandraLarge partition in Cassandra
Large partition in Cassandra
 
Apache Cassandra at the Geek2Geek Berlin
Apache Cassandra at the Geek2Geek BerlinApache Cassandra at the Geek2Geek Berlin
Apache Cassandra at the Geek2Geek Berlin
 
Apache Cassandra 2.0
Apache Cassandra 2.0Apache Cassandra 2.0
Apache Cassandra 2.0
 
Bulk Loading Data into Cassandra
Bulk Loading Data into CassandraBulk Loading Data into Cassandra
Bulk Loading Data into Cassandra
 
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016
 
Monitoring Cassandra at Scale (Jason Cacciatore, Netflix) | C* Summit 2016
Monitoring Cassandra at Scale (Jason Cacciatore, Netflix) | C* Summit 2016Monitoring Cassandra at Scale (Jason Cacciatore, Netflix) | C* Summit 2016
Monitoring Cassandra at Scale (Jason Cacciatore, Netflix) | C* Summit 2016
 
Cassandra concepts, patterns and anti-patterns
Cassandra concepts, patterns and anti-patternsCassandra concepts, patterns and anti-patterns
Cassandra concepts, patterns and anti-patterns
 
Cassandra Explained
Cassandra ExplainedCassandra Explained
Cassandra Explained
 
Understanding Data Consistency in Apache Cassandra
Understanding Data Consistency in Apache CassandraUnderstanding Data Consistency in Apache Cassandra
Understanding Data Consistency in Apache Cassandra
 
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...
 
One Billion Black Friday Shoppers on a Distributed Data Store (Fahd Siddiqui,...
One Billion Black Friday Shoppers on a Distributed Data Store (Fahd Siddiqui,...One Billion Black Friday Shoppers on a Distributed Data Store (Fahd Siddiqui,...
One Billion Black Friday Shoppers on a Distributed Data Store (Fahd Siddiqui,...
 
Apache Cassandra multi-datacenter essentials
Apache Cassandra multi-datacenter essentialsApache Cassandra multi-datacenter essentials
Apache Cassandra multi-datacenter essentials
 

Andere mochten auch

Cassandra Troubleshooting for 2.1 and later
Cassandra Troubleshooting for 2.1 and laterCassandra Troubleshooting for 2.1 and later
Cassandra Troubleshooting for 2.1 and laterJ.B. Langston
 
Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)
Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)
Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)Cyrille Le Clerc
 
Introduction to Cassandra Basics
Introduction to Cassandra BasicsIntroduction to Cassandra Basics
Introduction to Cassandra Basicsnickmbailey
 
Spotify: Automating Cassandra repairs
Spotify: Automating Cassandra repairsSpotify: Automating Cassandra repairs
Spotify: Automating Cassandra repairsDataStax Academy
 
Rethink of PaaS
Rethink of PaaSRethink of PaaS
Rethink of PaaSXu Wang
 
Capacity Planning Free Solution
Capacity Planning Free SolutionCapacity Planning Free Solution
Capacity Planning Free Solutionluanrjesus
 
AWS: Architecting for resilience & cost at scale
AWS: Architecting for resilience & cost at scaleAWS: Architecting for resilience & cost at scale
AWS: Architecting for resilience & cost at scaleJos Boumans
 
Devoxx UK: Reliability & Scale in AWS while letting you sleep through the night
Devoxx UK: Reliability & Scale in AWS while letting you sleep through the night Devoxx UK: Reliability & Scale in AWS while letting you sleep through the night
Devoxx UK: Reliability & Scale in AWS while letting you sleep through the night Jos Boumans
 
Cassandra 2.1 boot camp, Compaction
Cassandra 2.1 boot camp, CompactionCassandra 2.1 boot camp, Compaction
Cassandra 2.1 boot camp, CompactionJoshua McKenzie
 
Cassandra Community Webinar | Getting Started with Apache Cassandra with Patr...
Cassandra Community Webinar | Getting Started with Apache Cassandra with Patr...Cassandra Community Webinar | Getting Started with Apache Cassandra with Patr...
Cassandra Community Webinar | Getting Started with Apache Cassandra with Patr...DataStax Academy
 
Cassandra Summit 2014: Cassandra at Instagram 2014
Cassandra Summit 2014: Cassandra at Instagram 2014Cassandra Summit 2014: Cassandra at Instagram 2014
Cassandra Summit 2014: Cassandra at Instagram 2014DataStax Academy
 
Cassandra Day Denver 2014: Introduction to Apache Cassandra
Cassandra Day Denver 2014: Introduction to Apache CassandraCassandra Day Denver 2014: Introduction to Apache Cassandra
Cassandra Day Denver 2014: Introduction to Apache CassandraDataStax Academy
 
Hadoop - Splitting big problems into manageable pieces.
Hadoop - Splitting big problems into manageable pieces.Hadoop - Splitting big problems into manageable pieces.
Hadoop - Splitting big problems into manageable pieces.Nathan Milford
 
Introduction to Cassandra Architecture
Introduction to Cassandra ArchitectureIntroduction to Cassandra Architecture
Introduction to Cassandra Architecturenickmbailey
 
Cassandra Day SV 2014: Beyond Read-Modify-Write with Apache Cassandra
Cassandra Day SV 2014: Beyond Read-Modify-Write with Apache CassandraCassandra Day SV 2014: Beyond Read-Modify-Write with Apache Cassandra
Cassandra Day SV 2014: Beyond Read-Modify-Write with Apache CassandraDataStax Academy
 
Cassandra Read/Write Paths
Cassandra Read/Write PathsCassandra Read/Write Paths
Cassandra Read/Write Pathsjdsumsion
 

Andere mochten auch (20)

Cassandra Troubleshooting for 2.1 and later
Cassandra Troubleshooting for 2.1 and laterCassandra Troubleshooting for 2.1 and later
Cassandra Troubleshooting for 2.1 and later
 
Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)
Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)
Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)
 
Introduction to Cassandra Basics
Introduction to Cassandra BasicsIntroduction to Cassandra Basics
Introduction to Cassandra Basics
 
Spotify: Automating Cassandra repairs
Spotify: Automating Cassandra repairsSpotify: Automating Cassandra repairs
Spotify: Automating Cassandra repairs
 
Cassandra NoSQL Tutorial
Cassandra NoSQL TutorialCassandra NoSQL Tutorial
Cassandra NoSQL Tutorial
 
Rethink of PaaS
Rethink of PaaSRethink of PaaS
Rethink of PaaS
 
Capacity Planning Free Solution
Capacity Planning Free SolutionCapacity Planning Free Solution
Capacity Planning Free Solution
 
AWS: Architecting for resilience & cost at scale
AWS: Architecting for resilience & cost at scaleAWS: Architecting for resilience & cost at scale
AWS: Architecting for resilience & cost at scale
 
Devoxx UK: Reliability & Scale in AWS while letting you sleep through the night
Devoxx UK: Reliability & Scale in AWS while letting you sleep through the night Devoxx UK: Reliability & Scale in AWS while letting you sleep through the night
Devoxx UK: Reliability & Scale in AWS while letting you sleep through the night
 
One-Man Ops
One-Man OpsOne-Man Ops
One-Man Ops
 
Cassandra 2.1 boot camp, Compaction
Cassandra 2.1 boot camp, CompactionCassandra 2.1 boot camp, Compaction
Cassandra 2.1 boot camp, Compaction
 
Cassandra Community Webinar | Getting Started with Apache Cassandra with Patr...
Cassandra Community Webinar | Getting Started with Apache Cassandra with Patr...Cassandra Community Webinar | Getting Started with Apache Cassandra with Patr...
Cassandra Community Webinar | Getting Started with Apache Cassandra with Patr...
 
Cassandra Summit 2014: Cassandra at Instagram 2014
Cassandra Summit 2014: Cassandra at Instagram 2014Cassandra Summit 2014: Cassandra at Instagram 2014
Cassandra Summit 2014: Cassandra at Instagram 2014
 
Cassandra Day Denver 2014: Introduction to Apache Cassandra
Cassandra Day Denver 2014: Introduction to Apache CassandraCassandra Day Denver 2014: Introduction to Apache Cassandra
Cassandra Day Denver 2014: Introduction to Apache Cassandra
 
Hadoop - Splitting big problems into manageable pieces.
Hadoop - Splitting big problems into manageable pieces.Hadoop - Splitting big problems into manageable pieces.
Hadoop - Splitting big problems into manageable pieces.
 
Introduction to Cassandra Architecture
Introduction to Cassandra ArchitectureIntroduction to Cassandra Architecture
Introduction to Cassandra Architecture
 
Cassandra compaction
Cassandra compactionCassandra compaction
Cassandra compaction
 
Cacti
CactiCacti
Cacti
 
Cassandra Day SV 2014: Beyond Read-Modify-Write with Apache Cassandra
Cassandra Day SV 2014: Beyond Read-Modify-Write with Apache CassandraCassandra Day SV 2014: Beyond Read-Modify-Write with Apache Cassandra
Cassandra Day SV 2014: Beyond Read-Modify-Write with Apache Cassandra
 
Cassandra Read/Write Paths
Cassandra Read/Write PathsCassandra Read/Write Paths
Cassandra Read/Write Paths
 

Ähnlich wie Cassandra for Sysadmins

Cassandra & Python - Springfield MO User Group
Cassandra & Python - Springfield MO User GroupCassandra & Python - Springfield MO User Group
Cassandra & Python - Springfield MO User GroupAdam Hutson
 
Breakthrough OLAP performance with Cassandra and Spark
Breakthrough OLAP performance with Cassandra and SparkBreakthrough OLAP performance with Cassandra and Spark
Breakthrough OLAP performance with Cassandra and SparkEvan Chan
 
Design Patterns for Distributed Non-Relational Databases
Design Patterns for Distributed Non-Relational DatabasesDesign Patterns for Distributed Non-Relational Databases
Design Patterns for Distributed Non-Relational Databasesguestdfd1ec
 
High order bits from cassandra & hadoop
High order bits from cassandra & hadoopHigh order bits from cassandra & hadoop
High order bits from cassandra & hadoopsrisatish ambati
 
cassandra
cassandracassandra
cassandraAkash R
 
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
 
ScyllaDB: What could you do with Cassandra compatibility at 1.8 million reque...
ScyllaDB: What could you do with Cassandra compatibility at 1.8 million reque...ScyllaDB: What could you do with Cassandra compatibility at 1.8 million reque...
ScyllaDB: What could you do with Cassandra compatibility at 1.8 million reque...Data Con LA
 
Basics of Distributed Systems - Distributed Storage
Basics of Distributed Systems - Distributed StorageBasics of Distributed Systems - Distributed Storage
Basics of Distributed Systems - Distributed StorageNilesh Salpe
 
On Rails with Apache Cassandra
On Rails with Apache CassandraOn Rails with Apache Cassandra
On Rails with Apache CassandraStu Hood
 
Apache Cassandra @Geneva JUG 2013.02.26
Apache Cassandra @Geneva JUG 2013.02.26Apache Cassandra @Geneva JUG 2013.02.26
Apache Cassandra @Geneva JUG 2013.02.26Benoit Perroud
 
Dynamo cassandra
Dynamo cassandraDynamo cassandra
Dynamo cassandraWu Liang
 
High order bits from cassandra & hadoop
High order bits from cassandra & hadoopHigh order bits from cassandra & hadoop
High order bits from cassandra & hadoopsrisatish ambati
 

Ähnlich wie Cassandra for Sysadmins (20)

Cassandra & Python - Springfield MO User Group
Cassandra & Python - Springfield MO User GroupCassandra & Python - Springfield MO User Group
Cassandra & Python - Springfield MO User Group
 
Cassandra
CassandraCassandra
Cassandra
 
Cassandra
CassandraCassandra
Cassandra
 
Breakthrough OLAP performance with Cassandra and Spark
Breakthrough OLAP performance with Cassandra and SparkBreakthrough OLAP performance with Cassandra and Spark
Breakthrough OLAP performance with Cassandra and Spark
 
Cassandra no sql ecosystem
Cassandra no sql ecosystemCassandra no sql ecosystem
Cassandra no sql ecosystem
 
Design Patterns for Distributed Non-Relational Databases
Design Patterns for Distributed Non-Relational DatabasesDesign Patterns for Distributed Non-Relational Databases
Design Patterns for Distributed Non-Relational Databases
 
High order bits from cassandra & hadoop
High order bits from cassandra & hadoopHigh order bits from cassandra & hadoop
High order bits from cassandra & hadoop
 
cassandra
cassandracassandra
cassandra
 
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
 
ScyllaDB: What could you do with Cassandra compatibility at 1.8 million reque...
ScyllaDB: What could you do with Cassandra compatibility at 1.8 million reque...ScyllaDB: What could you do with Cassandra compatibility at 1.8 million reque...
ScyllaDB: What could you do with Cassandra compatibility at 1.8 million reque...
 
Cassndra (4).pptx
Cassndra (4).pptxCassndra (4).pptx
Cassndra (4).pptx
 
Basics of Distributed Systems - Distributed Storage
Basics of Distributed Systems - Distributed StorageBasics of Distributed Systems - Distributed Storage
Basics of Distributed Systems - Distributed Storage
 
On Rails with Apache Cassandra
On Rails with Apache CassandraOn Rails with Apache Cassandra
On Rails with Apache Cassandra
 
Cassandra at no_sql
Cassandra at no_sqlCassandra at no_sql
Cassandra at no_sql
 
Apache cassandra
Apache cassandraApache cassandra
Apache cassandra
 
Apache Cassandra @Geneva JUG 2013.02.26
Apache Cassandra @Geneva JUG 2013.02.26Apache Cassandra @Geneva JUG 2013.02.26
Apache Cassandra @Geneva JUG 2013.02.26
 
Dynamo cassandra
Dynamo cassandraDynamo cassandra
Dynamo cassandra
 
High order bits from cassandra & hadoop
High order bits from cassandra & hadoopHigh order bits from cassandra & hadoop
High order bits from cassandra & hadoop
 
Cassandra architecture
Cassandra architectureCassandra architecture
Cassandra architecture
 

Kürzlich hochgeladen

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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 CVKhem
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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 2024The Digital Insurer
 
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 2024The Digital Insurer
 
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 productivityPrincipled Technologies
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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 2024The Digital Insurer
 
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
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
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 RobisonAnna Loughnan Colquhoun
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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
 

Kürzlich hochgeladen (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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
 
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
 
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
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
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
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 

Cassandra for Sysadmins

  • 1. 101 for System Administrators nathan@milford.io twitter.com/NathanMilford http://blog.milford.io
  • 2. What is Cassandra? • It is a distributed, columnar database. • Originally created at Facebook in 2008, is now a top level Apache Project. • Combines the best features of Amazon's Dynamo (replication, mostly) and Google's Big Table (data model).
  • 6.  @ Rocking ~30 Billion impressions a month, like a bawse. Used for semi-persistent storage of recommendations. • 14 nodes in two data centers.   • Dell R610, 8 cores, 32G of RAM, 6 x 10K SAS drives. • Using 0.8 currently, just upgraded. In production since 0.4. • We use Hector. • ~70-80G per node, ~550G dataset unreplicated. • RP + OldNTS @ RF2.  PropFileSnitch, RW @ CL.ONE.   Excited for NTS   Excited for TTLs!
  • 7. How We Use Cassandra    +--------------+     |    Tomcat    | Tomcat serves Recs from Memcached.    +------------+-+          ^       | Flume ships logs to Hadoop DWH.         |       | L  Bunch of algos run against log data.   +-----+-----+ | O    | Memcached | | G Results are crammed into Cassandra.   +-----------+ | S         ^       |  Keyspace per algo.         |       | V  CacheWarmer... +-------+-----+ | I | CacheWarmer | | A  Sources recs from Cassandra (and other +-------------+ |         ^       | F sources)         |       | L  Dumps them in Memcached.   +-----+-----+ | U   | Cassandra | | M   +-----------+ | E         ^       |         |       v    +----+--------+    | Hadoop/Hive |    +-------------+ * Simplified Workflow
  • 8. Before I get too technical, relax. The following slides may sound complex at first,  but at the end of the day, to get your feet wet all you need to do is: yum install / apt-get install Define a Seed. Define Strategies. service cassandra start Go get a beer. In my experience, once the cluster has been setup there is not much else to do other than occasional tuning as you learn how your data behaves.
  • 9. Why Cassandra? • Minimal Administration. • No Single Point of Failure. • Scales Horizontally.  • Writes are durable. • Consistency is tuneable as needed on reads and writes. • Schema is flexible, can be updated live. • Handles failure gracefully, Cassandra is crash-only. • Replication is easy, Rack and Datacenter aware.
  • 10. Data Model Keyspace = {   Column Family: {     Row Key: {       Column Name: "Column Value"       Column Name: "Column Value"     }   } } A Keyspace is a container for Column Families. Analogous to a database in MySQL. A Column Family is a container for a group of columns.  Analagous to a table in MySQL. A Column is the basic unit.  Key, Value and Timestamp. A Row is a smattering of column data.
  • 11. Gossip  In config, define seed(s).    Used for intra-cluster communication.   Cluster self-assembles.  Works with failure detection.  Routes client requests.
  • 12. Pluggable Partitioning  RandomPartitioner (RP)  Orders by MD5 of the key.  Most common.  Distributes relatively evenly. There are others, but you probably will not use them.
  • 13. Distributed Hash Table: The Ring For Random Partitioner: • Ring is made up of a range from 0 to 2**127. • Token is MD5(Key). • Each node is given a slice of the ring o Initial token is defined, node owns that token up to the next node's initial token. Rock your tokens here: http://blog.milford.io/cassandra-token-calculator/
  • 14. Pluggable Topology Discovery Cassandra needs to know about your network to direct replica placement. Snitches inform Cassandra about it.  SimpleSnitch   Default, good for 1 data center.  RackInferringSnitch  Infers location from the IP's octets.  10.D.R.N (Data center, Rack, Node)  PropertyFileSnitch  cassandra-topology.properties  IP=DC:RACK (arbitrary values)  10.10.10.1=NY1:R1  EC2Snitch  Discovers AWS AZ and Regions.
  • 15. Pluggable Replica Placement  SimpleStratgy  Places replicas in the adjacent nodes on the ring.  NetworkTopologyStrategy  Used with property file snitch.  Explicitly pick how replicas are placed.  strategy_options = [{NY1:2, LA1:2}];
  • 16. Reading & Writing Old method uses Thrift which is usually abstracted using APIs (ex. Hector, PyCassa, PHPCass) Now we have CQL and JDBC! SELECT * FROM ColumnFamily WHERE rowKey='Name'; Since all nodes are equal, you can read and write to any node. The node you connect to becomes a Coordinator for that request and routes your data to the proper nodes. Connection pooling to nodes is sometimes handled by the API Framework, otherwise use RRDNS or HAProxy.
  • 17. Tunable Consistency It is difficult to keep replicas of data consistant across nodes, let alone across continents. In any distributed system you have to make tradeoffs between how consistent your dataset is versus how avaliable it is and how tolerant the system is of partitions. (a.k.a CAP theorm.) Cassandra chooses to focus on making the data avaliable and partition tolerant and empower you to chose how consistant you need it to be. Cassandra is awesomesauce because you choose what is more important to your query, consistency or latency.
  • 18. Per-Query Consistency Levels Latency increases the more nodes you have to involve. ANY:   For writes only. Writes to any avaliable node and expects Cassandra to sort it out. Fire and forget. ONE:   Reads or writes to the closest replica. QUORUM:   Writes to half+1 of the appropriate replicas before the operation is successful.  A read is sucessful when half+1 replicas agree on a value to return.   LOCAL_QUORUM:   Same as above, but only to the local datacenter in a multi-datacenter topology. ALL:   For writes, all replicas need to ack the write.  For reads, returns the record with the newest timestamp once all replicas reply.  In both cases, if we're missing even one replica, the operation fails.
  • 19. Cassandra Write Path  Cassandra identifies which node owns the token you're trying to write based on your partitioning, replication and placement strategies.  Data Written to CommitLog  Sequential writes to disk, kinda like a MySQL binlog.  Mostly written to, is only read from upon a restart.   Data Written to Memtable.  Acts as a Write-back cache of data.  Memtable hits a threshold (configurable) it is flushed to disk as an SSTable. An SSTable (Sorted String Table) is an immutable file on disk. More on compaction later.
  • 20. Cassandra Read Path  Cassandra identifies which node owns the token you're trying to read based on your partitioning, replication and placement strategies.  First checks the Bloom filter, which can save us some time.  A space-efficient structure that tests if a key is on the node.   False positives are possible.  False negatives are impossible.  Then checks the index.  Tells us which SStable file the data is in.  And how far into the SStable file to look so we don't need to scan the whole thing.
  • 21. Distributed Deletes  Hard to delete stuff in a distributed system.  Difficult to keep track of replicas.  SSTables are immutable.  Deleted items are tombstoned (marked for deletion).  Data still exists, just can't be read by API.  Cleaned out during major compaction, when SSTables are merged/remade.
  • 22. Compaction • When you have enough disparate SSTable files taking up space, they are merge sorted into single SSTable files. • An expensive process (lots of GC, can eat up half of your disk space) • Tombstones discarded. • Manual or automatic. • Pluggable in 1.0. • Leveled Compaction in 1.0
  • 23. Repair  Anti-Entropy and Read Repair  During node repair and QUORUM & ALL reads, ColumnFamilies are compared with replicas and discrepancies resolved.  Put manual repair in cron to run at an interval =< the value of GCGraceSeconds to catch old tombstones or risk forgotten deletes.  Hinted Handoff  If a node is down, writes spool on other nodes and are handed off then it comes back.  Sometimes left off, since a returning node can get flooded.
  • 24. Caching  Key Cache  Puts the location of keys in memory.  Improves seek times for keys on disk.  Enabled per ColumnFamily.  On by default at 200,000 keys.  Row Cache  Keeps full rows of hot data in memory.  Enable per ColumnFamily.  Skinny rows are more efficient. Row Cache is consulted first, then the Key Cache Will require a bit of tuning.
  • 25. Hardware RAM: Depends on use. Stores some   objects off Heap. CPU: More cores the better.     Cassandra is built with concurrency in mind. Disk: Cassandra tries to minimize random IO.  Minimum of 2      disks.  Keep CommitLog and Data on separate spindles.     RAID10 or RAID0 as you see fit.  I set mine up thus: 1 Disk = OS + Commitlog & RAID10 = DataSSTables Network:  1 x 1gigE is fine, more the better and Gossip and    Data can be defined on separate interfaces.
  • 26. What about 'Cloud' environments? EC2Snitch • Maps EC2 Regions to Racks • Maps EC2 Availability Zones to DCs • Use Network Topology Strategy Avoid EBS. Use RAID0/RAID10 across ephemeral drives. Replicate across Availability Zones. Netflix is moving to 100% Cassandra on EC2: http://www.slideshare.net/adrianco/migrating-netflix-from- oracle-to-global-cassandra 
  • 27. Installing RedHat rpm -i http://rpm.datastax.com/EL/6/x86_64/riptano-release-5-1.el6.noarch.rpm yum -y install apache-cassandra Debian  Add to /etc/apt/sources.list deb http://www.apache.org/dist/cassandra/debian unstable main deb-src http://www.apache.org/dist/cassandra/debian unstable main wget http://www.apache.org/dist/cassandra/KEYS -O- | sudo apt-key add - sudo apt-get update sudo apt-get install cassandra
  • 28. Config and Log Files  /etc/cassandra/conf/  cassandra.yaml  cassandra-env.sh  /var/log/cassandra/  cassandra.log  system.log  gc.log (If Enabled.)
  • 29. Hot Tips • Use Sun/Oracle JVM (1.6 u22+) • Use JNA Library. o Keep disk_access_mode as auto. o BTW, it is not using all your RAM, is like FS Cache. • Don't use autobootstrap, specify initial token. • Super columns impose a performance penalty. • Enable GC logging in cassandra-env.sh  • Don't use a large heap. (Yay off-heap caching!) • Don't use swap.
  • 30. Monitoring Install MX4J jar into class path or ping JMX directly. curl | grep | awk it into Nagios, Ganglia, Cacti or what have you.
  • 31. What to Monitor  Heap Size and Usage  CompactionStage  Garbage Collections  Compaction Count  IO Wait  Cache Hit Rate  RowMutationStage (Writes)  ReadStage  Active and Pending  Active and Pending
  • 32. Adding/Removing/Replacing Nodes  Adding a Node  Calculate new tokens.  Set correct initial token on the new node  Once it bootstrapped, nodetool move on other nodes.  Removing a Node  nodetool decommission drains data to other nodes  nodetool removetoken tells the cluster to get the data from other replicas (faster, more expensive on live nodes).  Replacing a Node  Bring up replacement node with same IP and token.  Run nodetool repair. 
  • 33. Useful nodetool commands. nodetool info - Displays node-level info. nodetool ring - Displays info on nodes on the ring. nodetool cfstats - Displays ColumnFamily statistics. nodetool tpstats - Displays what operations Cassandra is doing right now. nodetool netstats - Displays streaming information. nodetool drain - Flushes Memtables to SSTables on disk and stops accepting writes.  Useful before a restart to make startup quicker (no CommitLog to replay)
  • 39. Backups  Single Node Snapshot  nodetool snapshot   nodetool clearsnapshot  Makes a hardlink of SSTables that you can tarball.  Cluster-wide Snapshot.  clustertool global_snapshot  clustertool clear_global_snapshot  Just does local snapshots on all nodes.  To restore:  Stop the node.  Clear CommitLogs.  Zap *.db files in the Keyspace directory.  Copy the snapshot over from the snapshots subdirectory.  Start the node and wait for load to decrease.
  • 40. Shutdown Best Practice While Cassandra is crash-safe, you can make a cleaner shutdown and save some time during startup thus:  Make other nodes think this one is down.  nodetool -h $(hostname) -p 8080 disablegossip  Wait a few secs, cut off anyone from writing to this node.  nodetool -h $(hostname) -p 8080 dissablethrift  Flush all memtables to disk.  nodetool -h $(hostname) -p 8080 drain  Shut it down.  /etc/init.d/cassandra stop
  • 41. Rolling Upgrades From 0.7 you can do rolling upgrades. Check for cassandra.yaml changes!  On each node, one by one:  Shutdown as in previous slide, but do a snapshot after draining.  Remove old jars, rpms, debs. Your data will not be touched.  Add new jars, rpms, debs.  /etc/init.d/cassandra start  Wait for the node to come back up and for the other nodes to see it.  When done, before you run repair, on each node run:  nodetool -h $(hostname) -p 8080 scrub  This is rebuilding the sstables to make them up to date.  It is essentially a major compaction, without compacting, so it is a bit expensive.  Run repair on your nodes to clean up the data.  nodetool -h $(hostname) -p 8080 repair
  • 42. Join Us! http://www.meetup.com/NYC-Cassandra-User-Group/ We'll be ing You! These slides can be found here: http://www.slideshare.net/nmilford/cassandra-for-sysadmins