SlideShare a Scribd company logo
Cassandra โ€“ An Introduction

                                  Mikio L. Braun
                                    Leo Jugel

                               TU Berlin, twimpact

                                 LinuxTag Berlin
                                  13. Mai 2011




LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
What is NoSQL
 โ—   For many web applications, โ€œclassical data
     basesโ€ are not the right choice:
      โ—   Database is just used for storing objects.
      โ—   Consistency not essential.
      โ—   A lot of concurrent access.




LinuxTag Berlin, 13. 5. 2011     (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
NoSQL in comparison
Classical Databases                               NoSQL
Powerful query language                           very simple query language
Scales by using larger servers                    skales through clustering
(โ€œscaling upโ€)                                    (โ€œscaling outโ€)
Changes of database schema very costly            No fixed database schema
ACID: Atomicity, Consistency, Isolation,          Typically only โ€œeventually consistentโ€
Duratbility
Transactions, locking, etc.                       Typically no support for transactions etc.




LinuxTag Berlin, 13. 5. 2011     (c) 2011 by Mikio L. Braun      @mikiobraun, blog.mikiobraun.de
Brewer's CAP Theorem
 โ—   CAP: Consistency, Availability, Partition
     Tolerance
      โ—   Consistency: You never get old data.
      โ—   Availability: read/write operations always possible.
      โ—   Partition Tolerance: other guarantees hold even if
          network of servers break.
 โ—   You can only have two of these!



Gilbert, Lynch, Brewer's conjecture and the feasibility of consistent, available, partition-
tolerant web services, ACM SIGACT News, Volume 33, Issue 2, June 2002
LinuxTag Berlin, 13. 5. 2011     (c) 2011 by Mikio L. Braun     @mikiobraun, blog.mikiobraun.de
Homepage                       http://cassandra.apache.org
Language                       Java
History                        โ— Developed at Facebook for inbox search,
                               released as Open Source in July 2008
                               โ— Apache Incubator since March 2009

                               โ— Apache Top-Level since February 2010


Main Properties                โ— structured key value store

                               โ— โ€œeventually consistentโ€

                               โ— fully equivalent nodes

                               โ— cluster can be modified without restarting


Support                        DataStax (http://datastax.com)
Licence                        Apache 2.0

LinuxTag Berlin, 13. 5. 2011       (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Version 0.6.x and 0.7.x
 โ—   Most important changes in 0.7.x
      โ—   config file format changed from XML to YAML
      โ—   schema modification (ColumnFamilies) without
          restart
      โ—   Beginning support for secondary indices
 โ—   However, also problems with stability initially.




LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Inspirations for Cassandra
 โ—   Amazon Dynamo
      โ—   Clustering without dedicated master node
      โ—   Peer-to-peer discovery of nodes, HintedHintoff, etc.
 โ—   Google BigTable
      โ—   data model
      โ—   requires central master node
      โ—   Provides much more fine grained control:
            โ€“   which data should be stored together
            โ€“   on-the-fly compression, etc.


LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Installation
 โ—   Download tar.gz from
     http://cassandra.apache.org/download/
 โ—   Unpack
 โ—   ./conf contains config files
 โ—   ./bin/cassandra -f to start Cassandra, Ctrl-C to
     stop




LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Configuration
 โ—   Database
      โ—   Version 0.6.x: conf/storage-conf.xml
      โ—   Version 0.7.x: conf/cassandra.yaml
 โ—   JVM Parameters
      โ—   Version 0.6.x: bin/cassandra.in.sh
      โ—   Version 0.7.x: conf/cassandra-env.sh




LinuxTag Berlin, 13. 5. 2011    (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Cassandra's Data Model
Keyspace (= database)                                          byte arrays
  Column Family (= table)                     Row
              key                             {name1: value1, name2: value2, name3: value3, ...}


                                                                      column
                               strings
                                                                                 sorted by name!
                               sorted according to partitioner

    Super Column Family
                key
                                                key                      {name1: value1, ...}




LinuxTag Berlin, 13. 5. 2011             (c) 2011 by Mikio L. Braun      @mikiobraun, blog.mikiobraun.de
Example: Simple Object Store
   class Person {
       long id;
       String name;
       String affiliation;
   }

                                       Convert fields to byte arrays




                    Keyspace โ€œMyDatabaseโ€:
                        ColumnFamily โ€œPersonโ€:
                            โ€œ1โ€: {โ€œidโ€: โ€œ1โ€, โ€œnameโ€: โ€œMikio Braun, โ€œaffiliationโ€: โ€œTU Berlinโ€}




LinuxTag Berlin, 13. 5. 2011         (c) 2011 by Mikio L. Braun     @mikiobraun, blog.mikiobraun.de
Example: Index
   class Page {
       long id;
       โ€ฆ                                                                  Object data fields
       List<Links> links;
   }                            Keyspace โ€œMyDatabaseโ€
                                    ColumnFamily โ€œPagesโ€
   class Link {                         โ€œ3โ€: {โ€œidโ€: 3, โ€ฆ}
       long id;                         โ€œ4โ€: {โ€œidโ€: 4, โ€ฆ}
       ...                                                               Used for both, linking
       int numberOfHits;            ColumnFamily โ€œLinksโ€                 and indexing!
   }                                    โ€œ1โ€: {โ€œidโ€: 1, โ€œurlโ€: โ€ฆ}
                                        โ€œ17โ€. {โ€œidโ€: 17, โ€œurlโ€: โ€ฆ}

                                    ColumnFamily โ€œLinksPerPageByNumberOfHitsโ€
                                        โ€œ3โ€: { โ€œ00000132:00000001โ€: โ€œtโ€, โ€œ000025: 00000017โ€: โ€ฆ
                                        โ€œ4โ€: { โ€œ00000044:00000024โ€: โ€œtโ€, โ€ฆ }

      Here we exploit that
      columns are sorted
      by their names.                  Of course, everything encoded in byte arrays,
                                       not ASCII

LinuxTag Berlin, 13. 5. 2011      (c) 2011 by Mikio L. Braun     @mikiobraun, blog.mikiobraun.de
Are SuperColumnFamilies
                     necessary?

 โ—   Usually, you can replace a SuperColumnFamily
     by several CollumnFamilies.
 โ—   Since SuperColumnFamilies make the
     implementation and the protocol more compelx,
     there are also people advocating the remove
     SuperCFs... .



LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Cassandra's Architecture

                            MemTable                                Read Operation




                                            Flush
 Memory


 Disk




Write Operation            Commit Log                     SSTable          SSTable            SSTable




                                                                         Compaction!
 LinuxTag Berlin, 13. 5. 2011          (c) 2011 by Mikio L. Braun        @mikiobraun, blog.mikiobraun.de
Cassandras API
  โ—   THRIFT-based API
Read operations                                          Write operations
get                       single column                  insert                 single column
get_slice                 range of columns               batch_mutate           several columns in
multiget_slice            range of columns in                                   several rows
                          several rows                   remove                 single column
get_count                 column count                   truncate               while ColumnFamily
get_range_slice           several columns from
                          range of rows
get_indexed_slices range of columns from
                   index

Sonstige
login, describe_*, add/drop column family/keyspace                                      since 0.7.x


 LinuxTag Berlin, 13. 5. 2011        (c) 2011 by Mikio L. Braun      @mikiobraun, blog.mikiobraun.de
Cassandra Clustering
 โ—   Fully equivalent nodes, no master node.
 โ—   Bootstrapping requires seed node.
            โ€œStorage Proxyโ€



                  Node                  Node                  Node




                               Reads/writes according to consistency level

                  Query

LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Consistency Level and
                       Replication Factor
โ—Replication factor: On how many nodes is a
piece of data stored?

โ—   Consistency level:
Consistency Level
ANY                            A node has received the operation, even a
                               HintedHandoff node.
ONE                            One node has completed the request.
QUORUM                         Operation has completed on majority of nodes / newest
                               result is returned.
LOCAL_QUORUM                   QUORUM in local data center
GLOBAL_QUORUM                  QUORUM in global data center
ALL                            Wait till all nodes have completed the request


LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
How to deal with failure
โ—   As long as requirements of the consistency level can be
    met, everything is fine.
โ—   Hinted Handoff:
     โ—   A write operation for a faulty node is stored on another node and
         pushed to the other node once it is available again.
     โ—   Data won't be readable after write!
โ—   Read Repair:
     โ—   After read operation has completed, data will be compared and
         updated on all nodes in the background.




LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Libraries
Python        Pycassa: http://github.com/pycassa/pycass
              Telephus: http://github.com/driftx/Telephus
Java          Datanucleus JDO:http://github.com/tnine/Datanucleus-Cassandra-Plugin
              Hector: http://github.com/rantav/hector
              Kundera http://code.google.com/p/kundera/
              Pelops: http://github.com/s7/scale7-pelops
Grails        grails-cassandra: https://github.com/wolpert/grails-cassandra
.NET          Aquiles: http://aquiles.codeplex.com/
              FluentCassandra: http://github.com/managedfusion/fluentcassandra
Ruby          Cassandra: http://github.com/fauna/cassandra
PHP           phpcassa: http://github.com/thobbs/phpcassa
              SimpleCassie: http://code.google.com/p/simpletools-php/wiki/SimpleCassie


Or roll your own based on THRIFT http://thrift.apache.org/ :)




LinuxTag Berlin, 13. 5. 2011      (c) 2011 by Mikio L. Braun    @mikiobraun, blog.mikiobraun.de
TWIMPACT: An Application
 โ—   Real-time analysis of Twitter
 โ—   Trend analysis based on retweets
 โ—   Very high data rate (several million tweets per
     day, about 50 per second)




LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
TWIMPACT: twimpact.jp




LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
TWIMPACT: twimpact.com




LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Application Profile
 โ—   Information about tweets, users, and retweets
 โ—   Text matching for non-API-retweets
 โ—   Retweet frequency and user impact
 โ—   Operation profile:
              get_slice        get     get_slice     batch_mutate    insert   batch_mutate       remove
              (all)                    (range)       (one row)
  Fraction    50.1%            6.0%    0.1%          14.9%           21.5%    6.8%               0.8%
  Duration 1.1ms               1.7ms   0.8ms         0.9ms           1.1ms    0.8ms              1.2ms




LinuxTag Berlin, 13. 5. 2011            (c) 2011 by Mikio L. Braun     @mikiobraun, blog.mikiobraun.de
Practical Experiences with
                       Cassandra
 โ—   Very stable
 โ—   Read operations relatively expensive
 โ—   Multithreading leads to a huge performance
     increase
 โ—   Requires quite extensive tuning
 โ—   Clustering doesn't automatically lead to better
     performance
 โ—   Compaction leads to performance decrease of
     up to 50%

LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Performance through Multithreading
 โ—   Multithreading leads to much higher throughput
 โ—   How to achieve multithreading without locking
     support?
                                                                             64
                                                                             32
                                                                             16
                                                                             8
                                                                         4
                                                                         2



                                                                         1
                                                                                  Core i7,
                                                                                  4 cores
                                                                                  (2 + 2 HT)
LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Performance through Multithreading
 โ—   Multithreading leads to much higher throughput
 โ—   How to achieve multithreading without locking
     support?




LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Cassandra Tuning
 โ—   Tuning opportunities:
      โ—   Size of memtables, thresholds for flushes
      โ—   Size of JVM Heap
      โ—   Frequency and depth of compaction
 โ—   Where?
      โ—   MemTableThresholds etc. in conf/cassandra.yaml
      โ—   JVM Parameters in conf/cassandra-env.sh




LinuxTag Berlin, 13. 5. 2011      (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Overview of JVM GC
                                                                     Old Generation
                  Young Generation
                                                                                 CMSInitiatingOccupancyFraction




              โ€œEdenโ€           โ€œSurvivorsโ€
                                                                                         Additional memory
                                                                                         usage while GC
            up to a few hundred MB                                    dozens of GBs      is running

LinuxTag Berlin, 13. 5. 2011            (c) 2011 by Mikio L. Braun       @mikiobraun, blog.mikiobraun.de
Cassandra's Memory Usage




            Flush
                                              Memtables,
                                              indexes, etc.




Size of Memtable: 128M, JVM Heap: 3G, #CF: 12            Compaction
 LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun      @mikiobraun, blog.mikiobraun.de
Cassandra's Memory Usage
 โ—   Memtables may survive for a very long time (up
     to several hours)
      โ—   are placed in old generation
      โ—   GC has to process several dozen GBs
      โ—   heap to small, GC triggered too late
              ๏ƒž โ€œGC stormโ€
 โ—   Trade-off:
      โ—   I/O load vs. memory usage
 โ—   Do not neglect compaction!

LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
The Effects of GC and Compactions




                                                       GroรŸe
                                                        GC
                               Compaction




LinuxTag Berlin, 13. 5. 2011        (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Cluster vs Single Node
โ—   Our set-up:
     โ—   1 Cluster with six-core CPU and RAID 5 with 6 hard disks
     โ—   4 Cluster with six-core CPU and RAID 0 with 2 hard disks
โ—   Single node consistently performs 1,5-3 times better.
โ—   Possible causes:
     โ—   Overhead through network communication/consistency levels, etc.
     โ—   Hard disk performance significant
     โ—   Cluster still too small
โ—   Effectively available disk space:
     โ—   1 Cluster: 6 * 500 GB = 3TB with RAID 5 = 2.5 TB (83%)
     โ—   4 Cluster: 4 * 1TB = 4TB with replication factor 2 = 2TB (50%)

LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Alternatives
 โ—   MongoDB, CouchDB, redis, even
     memcached... .
 โ—   Persistency: Disk or RAM?
 โ—   Replication: Master/Slave or Peer-to-Peer?
 โ—   Sharding?
 โ—   Upcoming trend towards more complex query
     languages (Javascript), map-reduce operations,
     etc.


LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Summary: Cassandra
 โ—   Platform which scales well
 โ—   Active user and developer community
 โ—   Read operations quite expensive
 โ—   For optimal performance, extensive tuning
     necessary
 โ—   Depending on your application, eventually
     consistent and lack of transactions/locking might
     be problematic.


LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Links
โ—   Apache Cassandra http://cassandra.apache.org
โ—   Apache Cassandra Wiki
    http://wiki.apache.org/cassandra/FrontPage
โ—   DataStax Dokumentation fรผr Cassandra
    http://www.datastax.com/docs/0.7/index
โ—   My Blog: http://blog.mikiobraun.de
โ—   Twimpact: http://beta.twimpact.com




LinuxTag Berlin, 13. 5. 2011   (c) 2011 by Mikio L. Braun   @mikiobraun, blog.mikiobraun.de
Ad

More Related Content

Viewers also liked (6)

Cassandra Explained
Cassandra ExplainedCassandra Explained
Cassandra Explained
Eric Evans
ย 
Append only data stores
Append only data storesAppend only data stores
Append only data stores
Jan Kronquist
ย 
An Overview of Apache Cassandra
An Overview of Apache CassandraAn Overview of Apache Cassandra
An Overview of Apache Cassandra
DataStax
ย 
Cassandra Introduction & Features
Cassandra Introduction & FeaturesCassandra Introduction & Features
Cassandra Introduction & Features
DataStax Academy
ย 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcached
Jurriaan Persyn
ย 
Cassandra NoSQL Tutorial
Cassandra NoSQL TutorialCassandra NoSQL Tutorial
Cassandra NoSQL Tutorial
Michelle Darling
ย 
Cassandra Explained
Cassandra ExplainedCassandra Explained
Cassandra Explained
Eric Evans
ย 
Append only data stores
Append only data storesAppend only data stores
Append only data stores
Jan Kronquist
ย 
An Overview of Apache Cassandra
An Overview of Apache CassandraAn Overview of Apache Cassandra
An Overview of Apache Cassandra
DataStax
ย 
Cassandra Introduction & Features
Cassandra Introduction & FeaturesCassandra Introduction & Features
Cassandra Introduction & Features
DataStax Academy
ย 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcached
Jurriaan Persyn
ย 
Cassandra NoSQL Tutorial
Cassandra NoSQL TutorialCassandra NoSQL Tutorial
Cassandra NoSQL Tutorial
Michelle Darling
ย 

Similar to Cassandra - An Introduction (20)

C++0x
C++0xC++0x
C++0x
Vaibhav Bajaj
ย 
NoSql databases
NoSql databasesNoSql databases
NoSql databases
Murat ร‡akal
ย 
Using-The-Common-Space-DUG-Datatel-Miko
Using-The-Common-Space-DUG-Datatel-MikoUsing-The-Common-Space-DUG-Datatel-Miko
Using-The-Common-Space-DUG-Datatel-Miko
MIKO ..
ย 
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScriptLotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Bill Buchan
ย 
Dotnet interview qa
Dotnet interview qaDotnet interview qa
Dotnet interview qa
abcxyzqaz
ย 
Socket Programming In Python
Socket Programming In PythonSocket Programming In Python
Socket Programming In Python
didip
ย 
Summary of "Cassandra" for 3rd nosql summer reading in Tokyo
Summary of "Cassandra" for 3rd nosql summer reading in TokyoSummary of "Cassandra" for 3rd nosql summer reading in Tokyo
Summary of "Cassandra" for 3rd nosql summer reading in Tokyo
CLOUDIAN KK
ย 
olibc: Another C Library optimized for Embedded Linux
olibc: Another C Library optimized for Embedded Linuxolibc: Another C Library optimized for Embedded Linux
olibc: Another C Library optimized for Embedded Linux
National Cheng Kung University
ย 
Serialization in .NET
Serialization in .NETSerialization in .NET
Serialization in .NET
Abhi Arya
ย 
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft..."Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
Dataconomy Media
ย 
Framework Design Guidelines For Brussels Users Group
Framework Design Guidelines For Brussels Users GroupFramework Design Guidelines For Brussels Users Group
Framework Design Guidelines For Brussels Users Group
brada
ย 
Presentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStackPresentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStack
David Sanchez
ย 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
Skills Matter
ย 
Peyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futurePeyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_future
Takayuki Muranushi
ย 
Building services using windows azure
Building services using windows azureBuilding services using windows azure
Building services using windows azure
Suliman AlBattat
ย 
The Why and How of Scala at Twitter
The Why and How of Scala at TwitterThe Why and How of Scala at Twitter
The Why and How of Scala at Twitter
Alex Payne
ย 
Python Pants Build System for Large Codebases
Python Pants Build System for Large CodebasesPython Pants Build System for Large Codebases
Python Pants Build System for Large Codebases
Angad Singh
ย 
OrientDB introduction - NoSQL
OrientDB introduction - NoSQLOrientDB introduction - NoSQL
OrientDB introduction - NoSQL
Luca Garulli
ย 
C#ppt
C#pptC#ppt
C#ppt
Sambasivarao Kurakula
ย 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Bill Buchan
ย 
NoSql databases
NoSql databasesNoSql databases
NoSql databases
Murat ร‡akal
ย 
Using-The-Common-Space-DUG-Datatel-Miko
Using-The-Common-Space-DUG-Datatel-MikoUsing-The-Common-Space-DUG-Datatel-Miko
Using-The-Common-Space-DUG-Datatel-Miko
MIKO ..
ย 
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScriptLotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Bill Buchan
ย 
Dotnet interview qa
Dotnet interview qaDotnet interview qa
Dotnet interview qa
abcxyzqaz
ย 
Socket Programming In Python
Socket Programming In PythonSocket Programming In Python
Socket Programming In Python
didip
ย 
Summary of "Cassandra" for 3rd nosql summer reading in Tokyo
Summary of "Cassandra" for 3rd nosql summer reading in TokyoSummary of "Cassandra" for 3rd nosql summer reading in Tokyo
Summary of "Cassandra" for 3rd nosql summer reading in Tokyo
CLOUDIAN KK
ย 
olibc: Another C Library optimized for Embedded Linux
olibc: Another C Library optimized for Embedded Linuxolibc: Another C Library optimized for Embedded Linux
olibc: Another C Library optimized for Embedded Linux
National Cheng Kung University
ย 
Serialization in .NET
Serialization in .NETSerialization in .NET
Serialization in .NET
Abhi Arya
ย 
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft..."Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
Dataconomy Media
ย 
Framework Design Guidelines For Brussels Users Group
Framework Design Guidelines For Brussels Users GroupFramework Design Guidelines For Brussels Users Group
Framework Design Guidelines For Brussels Users Group
brada
ย 
Presentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStackPresentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStack
David Sanchez
ย 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
Skills Matter
ย 
Peyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futurePeyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_future
Takayuki Muranushi
ย 
Building services using windows azure
Building services using windows azureBuilding services using windows azure
Building services using windows azure
Suliman AlBattat
ย 
The Why and How of Scala at Twitter
The Why and How of Scala at TwitterThe Why and How of Scala at Twitter
The Why and How of Scala at Twitter
Alex Payne
ย 
Python Pants Build System for Large Codebases
Python Pants Build System for Large CodebasesPython Pants Build System for Large Codebases
Python Pants Build System for Large Codebases
Angad Singh
ย 
OrientDB introduction - NoSQL
OrientDB introduction - NoSQLOrientDB introduction - NoSQL
OrientDB introduction - NoSQL
Luca Garulli
ย 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Bill Buchan
ย 
Ad

More from Mikio L. Braun (8)

Bringing ML To Production, What Is Missing? AMLD 2020
Bringing ML To Production, What Is Missing? AMLD 2020Bringing ML To Production, What Is Missing? AMLD 2020
Bringing ML To Production, What Is Missing? AMLD 2020
Mikio L. Braun
ย 
Academia to industry looking back on a decade of ml
Academia to industry looking back on a decade of mlAcademia to industry looking back on a decade of ml
Academia to industry looking back on a decade of ml
Mikio L. Braun
ย 
Architecting AI Applications
Architecting AI ApplicationsArchitecting AI Applications
Architecting AI Applications
Mikio L. Braun
ย 
Machine Learning for Time Series, Strata London 2018
Machine Learning for Time Series, Strata London 2018Machine Learning for Time Series, Strata London 2018
Machine Learning for Time Series, Strata London 2018
Mikio L. Braun
ย 
Hardcore Data Science - in Practice
Hardcore Data Science - in PracticeHardcore Data Science - in Practice
Hardcore Data Science - in Practice
Mikio L. Braun
ย 
Data flow vs. procedural programming: How to put your algorithms into Flink
Data flow vs. procedural programming: How to put your algorithms into FlinkData flow vs. procedural programming: How to put your algorithms into Flink
Data flow vs. procedural programming: How to put your algorithms into Flink
Mikio L. Braun
ย 
Scalable Machine Learning
Scalable Machine LearningScalable Machine Learning
Scalable Machine Learning
Mikio L. Braun
ย 
Realtime Data Analysis Patterns
Realtime Data Analysis PatternsRealtime Data Analysis Patterns
Realtime Data Analysis Patterns
Mikio L. Braun
ย 
Bringing ML To Production, What Is Missing? AMLD 2020
Bringing ML To Production, What Is Missing? AMLD 2020Bringing ML To Production, What Is Missing? AMLD 2020
Bringing ML To Production, What Is Missing? AMLD 2020
Mikio L. Braun
ย 
Academia to industry looking back on a decade of ml
Academia to industry looking back on a decade of mlAcademia to industry looking back on a decade of ml
Academia to industry looking back on a decade of ml
Mikio L. Braun
ย 
Architecting AI Applications
Architecting AI ApplicationsArchitecting AI Applications
Architecting AI Applications
Mikio L. Braun
ย 
Machine Learning for Time Series, Strata London 2018
Machine Learning for Time Series, Strata London 2018Machine Learning for Time Series, Strata London 2018
Machine Learning for Time Series, Strata London 2018
Mikio L. Braun
ย 
Hardcore Data Science - in Practice
Hardcore Data Science - in PracticeHardcore Data Science - in Practice
Hardcore Data Science - in Practice
Mikio L. Braun
ย 
Data flow vs. procedural programming: How to put your algorithms into Flink
Data flow vs. procedural programming: How to put your algorithms into FlinkData flow vs. procedural programming: How to put your algorithms into Flink
Data flow vs. procedural programming: How to put your algorithms into Flink
Mikio L. Braun
ย 
Scalable Machine Learning
Scalable Machine LearningScalable Machine Learning
Scalable Machine Learning
Mikio L. Braun
ย 
Realtime Data Analysis Patterns
Realtime Data Analysis PatternsRealtime Data Analysis Patterns
Realtime Data Analysis Patterns
Mikio L. Braun
ย 
Ad

Recently uploaded (20)

Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
ย 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
ย 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
ย 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
ย 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
ย 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
ย 
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy ConsumptionDrupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Exove
ย 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
ย 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
ย 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
ย 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
ย 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
ย 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
ย 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
ย 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
ย 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
ย 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
ย 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
ย 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
ย 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
ย 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
ย 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
ย 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
ย 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
ย 
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy ConsumptionDrupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Exove
ย 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
ย 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
ย 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
ย 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
ย 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
ย 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
ย 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
ย 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
ย 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
ย 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
ย 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
ย 

Cassandra - An Introduction

  • 1. Cassandra โ€“ An Introduction Mikio L. Braun Leo Jugel TU Berlin, twimpact LinuxTag Berlin 13. Mai 2011 LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 2. What is NoSQL โ— For many web applications, โ€œclassical data basesโ€ are not the right choice: โ— Database is just used for storing objects. โ— Consistency not essential. โ— A lot of concurrent access. LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 3. NoSQL in comparison Classical Databases NoSQL Powerful query language very simple query language Scales by using larger servers skales through clustering (โ€œscaling upโ€) (โ€œscaling outโ€) Changes of database schema very costly No fixed database schema ACID: Atomicity, Consistency, Isolation, Typically only โ€œeventually consistentโ€ Duratbility Transactions, locking, etc. Typically no support for transactions etc. LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 4. Brewer's CAP Theorem โ— CAP: Consistency, Availability, Partition Tolerance โ— Consistency: You never get old data. โ— Availability: read/write operations always possible. โ— Partition Tolerance: other guarantees hold even if network of servers break. โ— You can only have two of these! Gilbert, Lynch, Brewer's conjecture and the feasibility of consistent, available, partition- tolerant web services, ACM SIGACT News, Volume 33, Issue 2, June 2002 LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 5. Homepage http://cassandra.apache.org Language Java History โ— Developed at Facebook for inbox search, released as Open Source in July 2008 โ— Apache Incubator since March 2009 โ— Apache Top-Level since February 2010 Main Properties โ— structured key value store โ— โ€œeventually consistentโ€ โ— fully equivalent nodes โ— cluster can be modified without restarting Support DataStax (http://datastax.com) Licence Apache 2.0 LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 6. Version 0.6.x and 0.7.x โ— Most important changes in 0.7.x โ— config file format changed from XML to YAML โ— schema modification (ColumnFamilies) without restart โ— Beginning support for secondary indices โ— However, also problems with stability initially. LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 7. Inspirations for Cassandra โ— Amazon Dynamo โ— Clustering without dedicated master node โ— Peer-to-peer discovery of nodes, HintedHintoff, etc. โ— Google BigTable โ— data model โ— requires central master node โ— Provides much more fine grained control: โ€“ which data should be stored together โ€“ on-the-fly compression, etc. LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 8. Installation โ— Download tar.gz from http://cassandra.apache.org/download/ โ— Unpack โ— ./conf contains config files โ— ./bin/cassandra -f to start Cassandra, Ctrl-C to stop LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 9. Configuration โ— Database โ— Version 0.6.x: conf/storage-conf.xml โ— Version 0.7.x: conf/cassandra.yaml โ— JVM Parameters โ— Version 0.6.x: bin/cassandra.in.sh โ— Version 0.7.x: conf/cassandra-env.sh LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 10. Cassandra's Data Model Keyspace (= database) byte arrays Column Family (= table) Row key {name1: value1, name2: value2, name3: value3, ...} column strings sorted by name! sorted according to partitioner Super Column Family key key {name1: value1, ...} LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 11. Example: Simple Object Store class Person { long id; String name; String affiliation; } Convert fields to byte arrays Keyspace โ€œMyDatabaseโ€: ColumnFamily โ€œPersonโ€: โ€œ1โ€: {โ€œidโ€: โ€œ1โ€, โ€œnameโ€: โ€œMikio Braun, โ€œaffiliationโ€: โ€œTU Berlinโ€} LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 12. Example: Index class Page { long id; โ€ฆ Object data fields List<Links> links; } Keyspace โ€œMyDatabaseโ€ ColumnFamily โ€œPagesโ€ class Link { โ€œ3โ€: {โ€œidโ€: 3, โ€ฆ} long id; โ€œ4โ€: {โ€œidโ€: 4, โ€ฆ} ... Used for both, linking int numberOfHits; ColumnFamily โ€œLinksโ€ and indexing! } โ€œ1โ€: {โ€œidโ€: 1, โ€œurlโ€: โ€ฆ} โ€œ17โ€. {โ€œidโ€: 17, โ€œurlโ€: โ€ฆ} ColumnFamily โ€œLinksPerPageByNumberOfHitsโ€ โ€œ3โ€: { โ€œ00000132:00000001โ€: โ€œtโ€, โ€œ000025: 00000017โ€: โ€ฆ โ€œ4โ€: { โ€œ00000044:00000024โ€: โ€œtโ€, โ€ฆ } Here we exploit that columns are sorted by their names. Of course, everything encoded in byte arrays, not ASCII LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 13. Are SuperColumnFamilies necessary? โ— Usually, you can replace a SuperColumnFamily by several CollumnFamilies. โ— Since SuperColumnFamilies make the implementation and the protocol more compelx, there are also people advocating the remove SuperCFs... . LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 14. Cassandra's Architecture MemTable Read Operation Flush Memory Disk Write Operation Commit Log SSTable SSTable SSTable Compaction! LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 15. Cassandras API โ— THRIFT-based API Read operations Write operations get single column insert single column get_slice range of columns batch_mutate several columns in multiget_slice range of columns in several rows several rows remove single column get_count column count truncate while ColumnFamily get_range_slice several columns from range of rows get_indexed_slices range of columns from index Sonstige login, describe_*, add/drop column family/keyspace since 0.7.x LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 16. Cassandra Clustering โ— Fully equivalent nodes, no master node. โ— Bootstrapping requires seed node. โ€œStorage Proxyโ€ Node Node Node Reads/writes according to consistency level Query LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 17. Consistency Level and Replication Factor โ—Replication factor: On how many nodes is a piece of data stored? โ— Consistency level: Consistency Level ANY A node has received the operation, even a HintedHandoff node. ONE One node has completed the request. QUORUM Operation has completed on majority of nodes / newest result is returned. LOCAL_QUORUM QUORUM in local data center GLOBAL_QUORUM QUORUM in global data center ALL Wait till all nodes have completed the request LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 18. How to deal with failure โ— As long as requirements of the consistency level can be met, everything is fine. โ— Hinted Handoff: โ— A write operation for a faulty node is stored on another node and pushed to the other node once it is available again. โ— Data won't be readable after write! โ— Read Repair: โ— After read operation has completed, data will be compared and updated on all nodes in the background. LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 19. Libraries Python Pycassa: http://github.com/pycassa/pycass Telephus: http://github.com/driftx/Telephus Java Datanucleus JDO:http://github.com/tnine/Datanucleus-Cassandra-Plugin Hector: http://github.com/rantav/hector Kundera http://code.google.com/p/kundera/ Pelops: http://github.com/s7/scale7-pelops Grails grails-cassandra: https://github.com/wolpert/grails-cassandra .NET Aquiles: http://aquiles.codeplex.com/ FluentCassandra: http://github.com/managedfusion/fluentcassandra Ruby Cassandra: http://github.com/fauna/cassandra PHP phpcassa: http://github.com/thobbs/phpcassa SimpleCassie: http://code.google.com/p/simpletools-php/wiki/SimpleCassie Or roll your own based on THRIFT http://thrift.apache.org/ :) LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 20. TWIMPACT: An Application โ— Real-time analysis of Twitter โ— Trend analysis based on retweets โ— Very high data rate (several million tweets per day, about 50 per second) LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 21. TWIMPACT: twimpact.jp LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 22. TWIMPACT: twimpact.com LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 23. Application Profile โ— Information about tweets, users, and retweets โ— Text matching for non-API-retweets โ— Retweet frequency and user impact โ— Operation profile: get_slice get get_slice batch_mutate insert batch_mutate remove (all) (range) (one row) Fraction 50.1% 6.0% 0.1% 14.9% 21.5% 6.8% 0.8% Duration 1.1ms 1.7ms 0.8ms 0.9ms 1.1ms 0.8ms 1.2ms LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 24. Practical Experiences with Cassandra โ— Very stable โ— Read operations relatively expensive โ— Multithreading leads to a huge performance increase โ— Requires quite extensive tuning โ— Clustering doesn't automatically lead to better performance โ— Compaction leads to performance decrease of up to 50% LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 25. Performance through Multithreading โ— Multithreading leads to much higher throughput โ— How to achieve multithreading without locking support? 64 32 16 8 4 2 1 Core i7, 4 cores (2 + 2 HT) LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 26. Performance through Multithreading โ— Multithreading leads to much higher throughput โ— How to achieve multithreading without locking support? LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 27. Cassandra Tuning โ— Tuning opportunities: โ— Size of memtables, thresholds for flushes โ— Size of JVM Heap โ— Frequency and depth of compaction โ— Where? โ— MemTableThresholds etc. in conf/cassandra.yaml โ— JVM Parameters in conf/cassandra-env.sh LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 28. Overview of JVM GC Old Generation Young Generation CMSInitiatingOccupancyFraction โ€œEdenโ€ โ€œSurvivorsโ€ Additional memory usage while GC up to a few hundred MB dozens of GBs is running LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 29. Cassandra's Memory Usage Flush Memtables, indexes, etc. Size of Memtable: 128M, JVM Heap: 3G, #CF: 12 Compaction LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 30. Cassandra's Memory Usage โ— Memtables may survive for a very long time (up to several hours) โ— are placed in old generation โ— GC has to process several dozen GBs โ— heap to small, GC triggered too late ๏ƒž โ€œGC stormโ€ โ— Trade-off: โ— I/O load vs. memory usage โ— Do not neglect compaction! LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 31. The Effects of GC and Compactions GroรŸe GC Compaction LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 32. Cluster vs Single Node โ— Our set-up: โ— 1 Cluster with six-core CPU and RAID 5 with 6 hard disks โ— 4 Cluster with six-core CPU and RAID 0 with 2 hard disks โ— Single node consistently performs 1,5-3 times better. โ— Possible causes: โ— Overhead through network communication/consistency levels, etc. โ— Hard disk performance significant โ— Cluster still too small โ— Effectively available disk space: โ— 1 Cluster: 6 * 500 GB = 3TB with RAID 5 = 2.5 TB (83%) โ— 4 Cluster: 4 * 1TB = 4TB with replication factor 2 = 2TB (50%) LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 33. Alternatives โ— MongoDB, CouchDB, redis, even memcached... . โ— Persistency: Disk or RAM? โ— Replication: Master/Slave or Peer-to-Peer? โ— Sharding? โ— Upcoming trend towards more complex query languages (Javascript), map-reduce operations, etc. LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 34. Summary: Cassandra โ— Platform which scales well โ— Active user and developer community โ— Read operations quite expensive โ— For optimal performance, extensive tuning necessary โ— Depending on your application, eventually consistent and lack of transactions/locking might be problematic. LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de
  • 35. Links โ— Apache Cassandra http://cassandra.apache.org โ— Apache Cassandra Wiki http://wiki.apache.org/cassandra/FrontPage โ— DataStax Dokumentation fรผr Cassandra http://www.datastax.com/docs/0.7/index โ— My Blog: http://blog.mikiobraun.de โ— Twimpact: http://beta.twimpact.com LinuxTag Berlin, 13. 5. 2011 (c) 2011 by Mikio L. Braun @mikiobraun, blog.mikiobraun.de