SlideShare una empresa de Scribd logo
1 de 141
Introduction à Cassandra
        Nicolas Romanetti
            @nromanetti

         www.jaxio.com


        mercredi 18 avril 2012




                                 1
University Talk


•   Tout public

•   3h pour vraiment comprendre Cassandra

•   Pédagogique




                                            2
University Talk

•   Démarre doucement

•   Continue doucement

•   Mais en 3h nous allons couvrir beaucoup de sujets

•   Devrait vous chatouiller un peu le cerveau

•   Conseil: prenez des notes



                                                        3
Cassandra LAN Party
   (Hands On Cassandra)


  Cet après midi
 de 13h30 à 16h30


                          4
A Propos

•   Nicolas Romanetti

•   @nromanetti

•   www.jaxio.com

•   Légitimité?




                               5
Cassandre


•   Très belle

•   Libre

•   Avait raison




                               6
Cassandra c’est...




                     7
Cassandra c’est...




                     8
Cassandra c’est...




                     9
Symétrique




             10
Conçue pour les pannes




                         11
RDBM
                        scalabilité
réplication

    indexes                           dénormalisation



    cache                              transaction



        join   performance

                                                        12
Très important




                 13
Installation de Cassandra




                            14
Historique

              Big Table
Dynamo




                          15
Data Model Cassandra

•   Attention au vocabulaire




                               16
Version courte



•   Une Map distribuée de Map




                                17
Column

   name

   value

 timestamp




             18
Row

      col. name1    col. name2    col. name3          col. nameN
Key                                             ...
      col. value1   col. value2   col. value3         col. valueN




                                                                    19
Exemple de Row
                  column                      col. name

                   prénom   profession    twitter
mick@stones.com
                    Mick    Musicien     @mjagger



                                              col. value
Row Key




                                                           20
Libre...
                          column                           col. name

row          qqun
                          tél fixe
                        0122334455
                                      tél mob.
                                     0612345678
                                                  prénom
                                                  Emma



                            fax       naissance   surnom       tél fixe
           qqunautre
                        0102020202   01/12/2000    Nico    0145060063




        Key                                       col. value



 comparator/validator
                                                                         21
Column Family

                           prénom        tél fixe        tél mob.
              qqun
                          Aurélien     0122334455     0612345678

user
                           fax       naissance        tél fixe
            qqunautre
                        0102020202   01/12/2000     0122334455




         user['qqun']['tél mob.'] = 0612345678



  col. Family row key col. name col. value


                                                                   22
cluster

          keyspace
           keyspace
            keyspace
    Column Family
     Column Family
      Column Family


row
 row
  row
    row   column   column   column




                                     23
Le nom est une valeur!

‘vol’
XK_4501_2012            6:55                    7:00               7:20
   _01_06                                                                      etc...
               décollage face à la mer   survol Capo di Feno   survol Cannes




                                                                                        24
Liens
‘BlogEntries’
                  2012/04/18 10:52         2012/04/12 10:12    2012/04/01 10:11
          jaxio                                                                   etc...
                      rowkeyA                   rowkeyB           rowkeyC




‘BlogEntry’
                                           😳😳
                        Content                   date                 Title
        rowkeyA                                                                        etc...
                  Plusieurs talks se ...    2012/04/18 10:52       DevoxxFR rox

    😳




                                                                                                25
Composite name, valueless
‘TopScores’
 2012/01/02
              093:toto   105:titi   106:tutu   etc...




                                                        26
Super column
                        nromanetti@jaxio.com


                                login
                                                                      ed
                                                                     t )
                                                                  caaitre
                               nroma
                                                                 e r
                               twitter
                                                       e prdispa
                            @nromanetti
                                                   D    (v
                                                             a


                                ville
                                Paris

    users['france']['nromanetti@jaxio.com']['ville'] = 'Paris'



  Super     row key   super                    sub col. sub
col. Family         col. name                   name col. value


                                                                            27
Fourre tout

   contactInfo



      tel:04...,
   email: nr@...,
   city: Ajaccio,
        etc...




                    28
Gros contenu


              0         1         2
Une_Video                                 etc...
            chunk_0   chunk_1   chunk_2




                                                   29
Column expirante


   name




   value




                   30
Compteur Distribué

      nb de like


       57832




                     31
Tombstone

            nom




                  32
Questions?




             33
Query

•   Attention au vocabulaire




                               34
2 types de row
Wide row
  key              ...   ...   ...


Skinny row
  key




                                     35
get
• get   user['toto']['firstname'];

• get   user['toto']['state'];




                                     36
Column Slice

                                    ...
            n1      n2      n5            n1033    n2323   n33444
Row Key
          qqchose qqchose qqchose         qqchose qqchose qqchose




                                     Slice



          ordre..



                                                                    37
Cassandra Query Language

• select   user where country = 'FR';


                          Secondary Index




                                            38
«Modélisation»



•   Avoir un don de prophétie




                                39
Disponibilité ☞ Réplication


                              40
Où stocker une row?

•   Tous les serveurs sont identiques (symétrie)

•   Postulats

    •   1 row doit tenir sur 1 seul serveur

    •   On veut répartir les rows uniformément




                                                   41
Consistent Hashing
  bytes        Consistent   Un ‘token’ entre
e.g. String      Hash         0 et 2^127
                                      0
                                          tokenB


 row keyA      f(keyA)
                            tokenA

  row keyB     f(keyB)
                             (2^127) / 2 ≃ 10^38




                                                   42
Consistent Hashing
                                                 tokenB
                                          N0

                                 N7                   N1    token1=1*(2^127)/8

                                                                  token range

token6=6*(2^127)/8          N6
                                                           N2    token2=2*(2^127)/8

                   tokenA

                                 N5                   N3

                                          N4


node 2 = contient 1ère replica des rows ayant leur token compris entre token1 et token2




                                                                                          43
nodetool ring




                44
Vocabulaire

      Node

Replication Factor

     Replica




                     45
Stratégie de placement
Replication Factor = 3
                                   tokenB
                              N0

                         N7            N1    1ère replica de la row ‘tokenB’




                    N6
                                            N2   2ème replica...

           tokenA

                         N5            N3    3ème replica...

                              N4




                                                                               46
API client


•   Hector... Frère de Cassandre

•   Astyanax (créé par Netflix)... Fils d’Hector

•   Driver CQL...

                          Thrift



                                                  47
Ecriture: qui contacter?
Client
         ?
                           N0
Thrift
                      N7        N1




                                     N2
                 N6




                      N5        N3
  Une replica?
                           N4




                                          48
Attendre les réponses?

                       N0
Client
                  N7                N1

                            ?
             N6
                                ?        N2




                  N5        ?       N3

                       N4




                                              49
solution: Tuneable Consistency



         CONSISTENCY LEVEL




                                 50
CL - ONE
  écriture




             51
Exemple 1
                                    1er qui répond
                               N0
  Client                                 ✓
           write          N7        N1




           OK        N6
                                         N2
                                              ?

                          N5        N3

RF = 3                                   ?
                               N4

CL = ONE

    asynchrone
                                                     52
Exemple 1 (suite)

                                   N0
  Client                                     ✓
                              N7        N1




                         N6
                                             N2
                                                  ✓

                              N5        N3

RF = 3                                       ✓
                                   N4

CL = ONE
            OK en background...


                                                      53
Exemple 2

                               N0
  Client                                 ✓
           write          N7        N1




           OK        N6
                                         N2
                                              ?

                          N5        N3

RF = 3                                   ?
                               N4

CL = ONE

    asynchrone
                                                  54
Exemple 2 (suite)

                                   N0
  Client                                     ✓
                             N7         N1




                        N6
                                    X        N2
                                                  ?

                             N5         N3

RF = 3                                       ✓
                                   N4

CL = ONE
             KO en background...

                                                      55
Exemple 3

                              N0
  Client
           write         N7
                                   X
                                   N1




           KO       N6                  X
                                        N2




RF = 3
                         N5
                                   X
                                   N3

                              N4

CL = ONE


                                             56
CL - QUORUM
    écriture




               57
Exemple 1

                               N0
  Client                                 ✓
           write          N7        N1




           OK        N6
                                         N2
                                              ✓

                          N5        N3

RF = 3                                   ?
                               N4

CL = QUORUM

    asynchrone
                                                  58
Exemple 1 (suite)

                                    N0
  Client                                      ✓
                            N7           N1




                       N6
                                              N2
                                                   ✓

                            N5           N3

RF = 3                                        ✓
                                    N4

CL = QUORUM
              OK en background...

                                                       59
Exemple 2

                               N0
  Client                                 ✓
           write          N7        N1




           OK        N6
                                         N2
                                              ✓

                          N5        N3

RF = 3                                   ?
                               N4

CL = QUORUM

    asynchrone
                                                  60
Exemple 2 (suite)

                                N0
  Client                                     ✓
                           N7           N1




                      N6
                                             N2
                                                  ✓

                           N5
                                    X   N3

RF = 3                                       ?
                                N4

CL = QUORUM
              KO en background...

                                                      61
Exemple 3

                               N0
  Client                                 ✓
           write          N7        N1




           KO        N6
                                    X    N2
                                              ?

                          N5        N3

RF = 3                         N4
                                         ?
CL = QUORUM

    asynchrone
                                                  62
Exemple 4

                              N0
  Client
           write         N7        N1




           KO       N6                  X
                                        N2




RF = 3
                         N5
                                   X
                                   N3

                              N4

CL = QUORUM


                                             63
CL - ALL
  écriture




             64
Exemple 1

                               N0
   Client                                ✓
            write         N7        N1




            OK       N6
                                         N2
                                              ✓

                          N5        N3

RF = 3                                   ✓
                               N4

CL = ALL


                                                  65
Exemple 2

                               N0
   Client                                ✓
            write         N7        N1




            KO       N6
                                    X    N2
                                              ?

                          N5        N3

RF = 3                                   ✓
                               N4

CL = ALL


                                                  66
Exemple 3

                               N0
   Client
            write         N7        N1




            KO       N6                  X
                                         N2




                          N5        N3

RF = 3                         N4

CL = ALL


                                              67
Sondage


Rollback ou pas?




                   68
Pas de Rollback...


•   La donnée va être propagée

•   Mais comment?




                                 69
Hinted Handoff

                                          N0
                                                    ✓
Client          write                N7        N1




                OK              N6
                                                    N2   ✓
                                 ✓
                        hint (ttl) N5
RF = 3
                                               X
                                               N3

                                          N4

CL = QUORUM

         asynchrone
                                                             70
Hinted Handoff

                           N0
                                       ✓
Client   write        N7          N1




   RF = 3
                 N6
                                       N2   ✓
CL=QUORUM

                      N5          N3
                                       ✓
                           N4

                            N3 revient dans le ring


                                                  71
Hinted Handoff


•   1er mécanisme de reprise sur erreur

•   TTL du hint




                                          72
CL - ANY
  écriture




             73
Exemple CL Any

                                     N0

Client      write             N7           N1



                              hint (ttl)
           Tjs OK!       N6
                                                N2

                     ✓
                              N5           N3

RF = 3                               N4

CL = ANY


                                                     74
Etat du ring?




                75
Gossip Protocol
                            N0

                       N7           N1




                  N6                     X
                                         N2




                       N5           N3

•   Pas d’ilots             N4



•   Découverte du ring

•   Echange d’info sur le système

                                              76
∿φ Accrual Failure Detector



•   Ni oui ni non

•   Probabiliste




                                   77
Expiration du hint



•   Comment synchroniser les données lorsque le noeud
    revient dans le ring après expiration des hints?




                                                        78
Anti-Entropy
                              N0
                                                  ✓
                         N7                 N1


hint




                                   anti-entropy
                    N6
                                                  N2   ✓

                         N5                 N3



               re pair        N4

       n ode

               2ème mécanisme de reprise sur erreur


                                                           79
Merkle Tree (1982)




                     80
En lecture



•   Tuneable consistency




                               81
CL - ONE
  lecture




            82
Exemple 1
                                                 Pourquoi N1 ?
                                         N0
   Client                                            v2
            read              N7                N1


                                    re ad
                                       digest             v1
            OK           N6
                                                     N2


            v2                     dig
                                         est
                              N5                N3

                                         N4          v2

RF = 3      Donnée la plus récente parmi ONE replica
CL = ONE

                                                                 83
Exemple 1 (suite)
                                  N0
   Client                                        v2
                         N7                 N1




                    N6
                              read repair        N2   v1 => v2


                         N5                 N3

                                  N4             v2

RF = 3
CL = ONE

                                                             84
Exemple 2
                                         N0
   Client                                            v1
            read              N7                N1


                                    re ad
                                       digest             v1
            OK           N6
                                                     N2


            v1                     dig
                                         est
                              N5                N3

                                         N4          v2

RF = 3      Donnée la plus récente parmi ONE replica
CL = ONE

                                                               85
Exemple 2 (suite)
                               N0
   Client                                       v1 => v2
                         N7
                                    a ir   N1

                              r ep
                            ad
                          re read repair
                    N6
                                                N2   v1 => v2


                         N5                N3

                               N4               v2

RF = 3
CL = ONE

                                                            86
Read Repair


•   3ème mécanisme de reprise sur erreur

•   Configurable (% de chance)




                                           87
CL - QUORUM
    lecture




              88
Exemple 1
                                      N0
   Client                                            v2
            read               N7               N1


                                    re ad
                                       digest             v1
            OK            N6
                                                     N2

                                       + read
            v2
                               N5               N3

                                      N4             v2

RF = 3             Donnée la plus récente parmi 2 replicas
CL = QUORUM

                                                               89
Exemple 1 (suite)
                                 N0
   Client                                    v2
                         N7             N1




                    N6
                              read repair    N2   v1 => v2


                         N5             N3

                                 N4          v2

RF = 3
CL = QUORUM

                                                         90
Exemple 2
                               N0
   Client                                v2
            read          N7        N1




            KO       N6
                                         X
                                         N2   v1


                          N5
                                    X v2
                                    N3

                               N4




RF = 3
CL = QUORUM

                                                   91
CL - ALL
  lecture




            92
Exemple 1
                                          N0
   Client                                             v2
            read               N7                N1


                                     re ad
                                        digest             v2
            OK            N6
                                                      N2


            v2                      dig
                                          est
                               N5                N3

                                          N4          v2

RF = 3             Donnée la plus récente parmi 3 replicas
CL = ALL

                                                                93
Consistence Forte

•   Comment être certain que la donnée lue est la plus
    récente?

•   formule        W + R > RF
        W: nb de replica contactées en écriture
         R: nb de replica contactées en lecture
        RF: replication factor

•   Cas trivial: écriture en ALL et lecture en ONE



                                                         94
Consistency
                             RF = 3
             N0    QUORUM                       N0   QUORUM
     N7            N1
                                       N7               N1



          Write                             Write
                        N2
N6                                                           N2
                                  N6



          Read                              Read
     N5            N3
                                       N5               N3

             N4
                                                        QUORUM
                                                N4

                   ONE
          «Weak»                             «Strong»

                                                                  95
Démo - calculer Token
import java.math.BigInteger;

public class SimpleTokenCalculator {

    public static void main(String args[]) {
        int nbNodes = Integer.parseInt(args[0]);

        for (int i = 0; i < nbNodes; i++) {
            BigInteger token = new BigInteger("2");
            token = token.pow(127);
            token = token.multiply(new BigInteger("" + i));
            token = token.divide(new BigInteger("" + nbNodes));
            System.out.println("token " + i + ": " + token);
        }
    }
}


                                                                  96
Démo - création KS + CF
•   create keyspace ks with placement_strategy =
    'SimpleStrategy' and strategy_options =
    {replication_factor:2};

•   use ks;

•   create column family user with key_validation_class =
    'AsciiType' and comparator = 'AsciiType' and
    default_validation_class = 'AsciiType';

•   set user['antonio@devoxx.fr']['nom']= 'Goncalves';

•   get user['antonio@devoxx.fr'];




                                                            97
Questions?




             98
Performance en écriture



•   En écriture, Cassandra est extrêmement rapide,
    pourquoi?




                                                     99
Performance en écriture
Mémoire
                   MemTable
           put
ap
  pe
  nd




          Commit
           Log

Fichier

                                 100
c1 c2 c3
Mémoire                         k1




              put
                                                MemTable
ap
  pe
  nd




       - write (k1: c1,c2,c3)




         Commit Log


                                                           101
c1 c2 c3 c4
                                k1




              put
                                                   MemTable
ap
  pe
  nd




       - write (k1: c1,c2,c3)
       - write(k1: c4)




         Commit Log


                                                              102
c1 c2 c3 c4
                                k1


                                     c3
                                k2

              put
                                                   MemTable
ap
  pe
  nd




       - write (k1: c1,c2,c3)
       - write(k1: c4)
       - write(k2, c3)




         Commit Log


                                                              103
c1 c2 c3 c4
                                k1


                                     c3
                                k2

              put
                                                   MemTable
ap
  pe
  nd




       - write (k1: c1,c2,c3)
       - write(k1: c4)
       - write(k2, c3)
       - delete(k1,c2)


         Commit Log


                                                              104
MemTable
      drop              flush
                    c1 c2 c3 c4        c3   SSTable 1 (read-only)
               k1                 k2



             sur disque distinct

Commit Log      Pourquoi conserver la tombstone?


                                                                    105
Delete distribué




•   Grace period:10 jours par défaut




                                       106
c3
                         k1


                              c4
                         k2
            put
                                                      MemTable
ap
  pe
  nd




       - write(k1: c3)   k1
                              c1 c2 c3 c4
                                            k2
                                                 c3   SSTable 1 (read-only)
       - write(k2: c4)




       Commit Log


                                                                              107
Pas d’update au flush

                                            MemTable
      drop             flush
                  c1 c2 c3 c4          c3   SSTable 1 (read-only)
             k1                   k2




                  c3             c4
             k1             k2              SSTable 2 (read-only)

Commit Log


                                                                    108
Backups?



•   SSTables sont readonly....




                                 109
Quid de la lecture?
                               c3
                          k1


                               c4
                          k2
           put
                                                         MemTable
ap
  pe
  nd




       - write(k1: c3)         c1 c2 c3 c4          c3   SSTable 1 (read-only)
                          k1                   k2
       - write (k2, c4)



                               c3             c4
                          k1             k2              SSTable 2 (read-only)

       Commit Log


                                                                                 110
Compaction
                                 c3            si < grace period

     c1 c2 c3 c4          c3
k1                   k2


                                           c1 c2 c3 c4        c3 c4
                                      k1                 k2

     c3             c4
k1             k2




                                                                      111
Lecture
           MemTable




Mémoire

Fichiers
            SSTable
             SSTable
              SSTable    6- Contient la valeur...




                                                    112
Lecture
           MemTable      1- Pertinent lorsque le client spécifie le nom de la colonne




           Row Cache




Mémoire

Fichiers
            SSTable
             SSTable
              SSTable    6- Contient la valeur...




                                                                                       113
Lecture
            MemTable        1- Pertinent lorsque le client spécifie le nom de la colonne




           Row Cache        2- Stocke l’intégralité d’une row


           BloomFilter
            BloomFilter
             BloomFilter




Mémoire

Fichiers
             SSTable
              SSTable
               SSTable      6- Contient la valeur...




                                                                                          114
Bloom Filter (création)
             key1

   f(key1)    g(key1)




                          115
Bloom Filter (création)
             key2

   f(key2)
             g(key2)




                          116
Bloom Filter (lecture)
             keyX

   f(keyX)    g(keyX)




   keyX présent? NON...




                          117
Bloom Filter (lecture)
                key2

      f(key2)
                g(key2)




 key2 présent? OUI... vrai positif




                                     118
Bloom Filter (lecture)
                      keyY

                   f(keyY) g(keyY)




keyY présent? OUI... mais c’est un faux positif




                                                  119
Lecture
            MemTable        1- Pertinent lorsque le client spécifie le nom de la colonne




           Row Cache        2- Stocke l’intégralité d’une row


           BloomFilter
            BloomFilter     3- répond à «La SSTable contient-elle un fragment de row ?»
             BloomFilter    Attention, faux positif possible.


            Key Cache


Mémoire

Fichiers
             SSTable
              SSTable
               SSTable      6- Contient la valeur...




                                                                                          120
Lecture
            MemTable        1- Pertinent lorsque le client spécifie le nom de la colonne




            Row Cache       2- Stocke l’intégralité d’une row


           BloomFilter
            BloomFilter     3- répond à «La SSTable contient-elle un fragment de row ?»
             BloomFilter    Attention, faux positif possible.


            Key Cache       4- Donne la position exacte du fragment de row dans la SSTable



Mémoire    Index Summary



Fichiers
              SSTable
               SSTable
                SSTable     6- Contient la valeur...




                                                                                             121
Lecture
            MemTable        1- Pertinent lorsque le client spécifie le nom de la colonne




            Row Cache       2- Stocke l’intégralité d’une row


           BloomFilter
            BloomFilter     3- répond à «La SSTable contient-elle un fragment de row ?»
             BloomFilter    Attention, faux positif possible.


            Key Cache       4- Donne la position exacte du fragment de row dans la SSTable



Mémoire    Index Summary    5- Donne la position approximative (intervalle) du fragment de row dans la
                            SSTable




Fichiers
              SSTable
               SSTable
                SSTable     6- Contient la valeur...




                                                                                                         122
Questions?




             123
Multi Data Center
                DC USA                                  DC Europe
                     Rack 1                                   Rack 1
         Replica 1    token o                                  token n

                      token s                                  token r   Replica 4
                      token w                                  token v




                     Rack 2                                   Rack 2
         Replica 3    token q                                  token p    Replica 2

RF = 4                token u

                      token y
                                                               token t

                                                               token x




                             Pas de symétrie entre les DC
                     QUORUM implique nécessairement 2 DC => latence



                                                                                      124
DataCenter «Aware»
                 NetworkTopologyStrategy + alternance tokens
RF = 3                                                      RF = 3
  DC USA                                       DC Europe
     Rack 1                                           Rack 1
     token n+1                                         token n

     token p+1     Replica 4                           token p   Replica 1
     token r+1     Replica 6                           token r   Replica 3




    Rack 2                                            Rack 2
     token o+1                                         token o

     token q+1     Replica 5                           token q   Replica 2
     token s+1                                         token s




                                                                             125
Ring 2 DataCenter (+1)
                                 token n

                                token n+1

                                rack 1
 rack 2   token s   token s+1                token o    token o+1   rack 2



 rack 1   token r   token r+1               token p    token p+1    rack1
                                rack 2
                                 token q

Europe                          token q+1


USA
                                                                             126
Latence du QUORUM
             RF = 3            RF = 3

               DC USA           DC Europe
                  Rack 1           Rack 1
Client
                           ☹


                 Rack 2            Rack 2




                                            127
LOCAL_QUORUM
           RF = 3            RF = 3
             DC USA           DC Europe
                Rack 1            Rack 1
Client




                         ☺
                Rack 2            Rack 2




                                           128
EACH_QUORUM
           RF = 3       RF = 3
             DC USA      DC Europe
               Rack 1       Rack 1
Client




               Rack 2       Rack 2

                             token q

                             token s




                                       129
Autres usages Multi DC


•   1 DC pour backup

•   1 DC pour traitement particulier




                                       130
Doubler la taille du cluster
            0

        t       n




    s
                    o   2*(2^127)/8



        r       p

            q




                                      131
Doubler la taille du cluster
          t + n/2             n/2

                        0

                 t             n
                                            (n+o)/2   3*(2^127)/16
(s+t)/2



          s
                                      o   2*(2^127)/8 = 4*(2^127)/16


(r+s)/2                                     (o+p)/2
                 r             p

                        q

              (q+r)/2       (p+q)/2




                                                                       132
Ajouter 1 noeud
                 0

          t              n
                                 n’’ 2*(2^127)/9


                             o
      s




          r              p

                 q




On crée un déséquilibre...

                                                   133
Ajouter 1 noeud
        0                                  0

                                 t’                 n’
    t         n


                  n’’
                           s’                            n’’
                    o
s


                            r’                           o’

    r         p
                                      q’       p’
        q



                  re-balancing

                                                               134
Ajout/Retrait/Upgrade



•   Se font à chaud




                             135
Architecture Interne & Monitoring


                                                                               Stage z




                                                               evt en sortie
                                                                                     Stage y




                                                               Traitement de l’evt par une thread
                                            Stage x                      (thread pool)

           les evts font la queue
certains peuvent expirer avant d’être traité!



                   SEDA: Staged Event-Driven Architecture...



                                                                                                    136
Architecture Interne & Monitoring

•    Monitoring des «stages» cassandra:
     (‘tp’ pour thread pool)
     (1) => 1 thread seulement


    Pool Name                     Active    Pending   Completed   Blocked   All time blocked
    ReadStage                          0          0           1         0                  0
    RequestResponseStage               0          0           0         0                  0
    MutationStage                      0          0          20         0                  0
    ReadRepairStage (1)                0          0           0         0                  0
    ReplicateOnWriteStage              0          0           0         0                  0
    GossipStage (1)                    0          0       86919         0                  0
    AntiEntropyStage (1)               0          0           0         0                  0
    MigrationStage (1)                 0          0           0         0                  0
    MemtablePostFlusher                0          0           4         0                  0
    StreamStage                        0          0           0         0                  0
    FlushWriter                        0          0           4         0                  0
    MiscStage (1)                      0          0           0         0                  0
    InternalResponseStage              0          0           0         0                  0
    HintedHandoff                      0          0          13         0                  0

    Message type            Dropped
    RANGE_SLICE                   0
    READ_REPAIR                   0
    BINARY                        0        Messages expirés sont «droppés»
    READ                          0
    MUTATION                      0
    REQUEST_RESPONSE              0




                                                                                               137
Une critique... si si



            •   Difficile de rentrer
                dans le code source




                                      138
Une critique... si si



            •   Difficile de rentrer
                dans le code source




                                      139
Questions?




             140
Pour approfondir




http://www.datastax.com/docs/1.0/index

http://wiki.apache.org/cassandra/

http://ria101.wordpress.com/2010/02/24/hbase-vs-cassandra-why-we-moved/

                                                                          141

Más contenido relacionado

Destacado

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Destacado (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Introduction à Cassandra - devoxx france 2012

  • 1. Introduction à Cassandra Nicolas Romanetti @nromanetti www.jaxio.com mercredi 18 avril 2012 1
  • 2. University Talk • Tout public • 3h pour vraiment comprendre Cassandra • Pédagogique 2
  • 3. University Talk • Démarre doucement • Continue doucement • Mais en 3h nous allons couvrir beaucoup de sujets • Devrait vous chatouiller un peu le cerveau • Conseil: prenez des notes 3
  • 4. Cassandra LAN Party (Hands On Cassandra) Cet après midi de 13h30 à 16h30 4
  • 5. A Propos • Nicolas Romanetti • @nromanetti • www.jaxio.com • Légitimité? 5
  • 6. Cassandre • Très belle • Libre • Avait raison 6
  • 11. Conçue pour les pannes 11
  • 12. RDBM scalabilité réplication indexes dénormalisation cache transaction join performance 12
  • 15. Historique Big Table Dynamo 15
  • 16. Data Model Cassandra • Attention au vocabulaire 16
  • 17. Version courte • Une Map distribuée de Map 17
  • 18. Column name value timestamp 18
  • 19. Row col. name1 col. name2 col. name3 col. nameN Key ... col. value1 col. value2 col. value3 col. valueN 19
  • 20. Exemple de Row column col. name prénom profession twitter mick@stones.com Mick Musicien @mjagger col. value Row Key 20
  • 21. Libre... column col. name row qqun tél fixe 0122334455 tél mob. 0612345678 prénom Emma fax naissance surnom tél fixe qqunautre 0102020202 01/12/2000 Nico 0145060063 Key col. value comparator/validator 21
  • 22. Column Family prénom tél fixe tél mob. qqun Aurélien 0122334455 0612345678 user fax naissance tél fixe qqunautre 0102020202 01/12/2000 0122334455 user['qqun']['tél mob.'] = 0612345678 col. Family row key col. name col. value 22
  • 23. cluster keyspace keyspace keyspace Column Family Column Family Column Family row row row row column column column 23
  • 24. Le nom est une valeur! ‘vol’ XK_4501_2012 6:55 7:00 7:20 _01_06 etc... décollage face à la mer survol Capo di Feno survol Cannes 24
  • 25. Liens ‘BlogEntries’ 2012/04/18 10:52 2012/04/12 10:12 2012/04/01 10:11 jaxio etc... rowkeyA rowkeyB rowkeyC ‘BlogEntry’ 😳😳 Content date Title rowkeyA etc... Plusieurs talks se ... 2012/04/18 10:52 DevoxxFR rox 😳 25
  • 26. Composite name, valueless ‘TopScores’ 2012/01/02 093:toto 105:titi 106:tutu etc... 26
  • 27. Super column nromanetti@jaxio.com login ed t ) caaitre nroma e r twitter e prdispa @nromanetti D (v a ville Paris users['france']['nromanetti@jaxio.com']['ville'] = 'Paris' Super row key super sub col. sub col. Family col. name name col. value 27
  • 28. Fourre tout contactInfo tel:04..., email: nr@..., city: Ajaccio, etc... 28
  • 29. Gros contenu 0 1 2 Une_Video etc... chunk_0 chunk_1 chunk_2 29
  • 30. Column expirante name value 30
  • 31. Compteur Distribué nb de like 57832 31
  • 32. Tombstone nom 32
  • 34. Query • Attention au vocabulaire 34
  • 35. 2 types de row Wide row key ... ... ... Skinny row key 35
  • 36. get • get user['toto']['firstname']; • get user['toto']['state']; 36
  • 37. Column Slice ... n1 n2 n5 n1033 n2323 n33444 Row Key qqchose qqchose qqchose qqchose qqchose qqchose Slice ordre.. 37
  • 38. Cassandra Query Language • select user where country = 'FR'; Secondary Index 38
  • 39. «Modélisation» • Avoir un don de prophétie 39
  • 41. Où stocker une row? • Tous les serveurs sont identiques (symétrie) • Postulats • 1 row doit tenir sur 1 seul serveur • On veut répartir les rows uniformément 41
  • 42. Consistent Hashing bytes Consistent Un ‘token’ entre e.g. String Hash 0 et 2^127 0 tokenB row keyA f(keyA) tokenA row keyB f(keyB) (2^127) / 2 ≃ 10^38 42
  • 43. Consistent Hashing tokenB N0 N7 N1 token1=1*(2^127)/8 token range token6=6*(2^127)/8 N6 N2 token2=2*(2^127)/8 tokenA N5 N3 N4 node 2 = contient 1ère replica des rows ayant leur token compris entre token1 et token2 43
  • 45. Vocabulaire Node Replication Factor Replica 45
  • 46. Stratégie de placement Replication Factor = 3 tokenB N0 N7 N1 1ère replica de la row ‘tokenB’ N6 N2 2ème replica... tokenA N5 N3 3ème replica... N4 46
  • 47. API client • Hector... Frère de Cassandre • Astyanax (créé par Netflix)... Fils d’Hector • Driver CQL... Thrift 47
  • 48. Ecriture: qui contacter? Client ? N0 Thrift N7 N1 N2 N6 N5 N3 Une replica? N4 48
  • 49. Attendre les réponses? N0 Client N7 N1 ? N6 ? N2 N5 ? N3 N4 49
  • 50. solution: Tuneable Consistency CONSISTENCY LEVEL 50
  • 51. CL - ONE écriture 51
  • 52. Exemple 1 1er qui répond N0 Client ✓ write N7 N1 OK N6 N2 ? N5 N3 RF = 3 ? N4 CL = ONE asynchrone 52
  • 53. Exemple 1 (suite) N0 Client ✓ N7 N1 N6 N2 ✓ N5 N3 RF = 3 ✓ N4 CL = ONE OK en background... 53
  • 54. Exemple 2 N0 Client ✓ write N7 N1 OK N6 N2 ? N5 N3 RF = 3 ? N4 CL = ONE asynchrone 54
  • 55. Exemple 2 (suite) N0 Client ✓ N7 N1 N6 X N2 ? N5 N3 RF = 3 ✓ N4 CL = ONE KO en background... 55
  • 56. Exemple 3 N0 Client write N7 X N1 KO N6 X N2 RF = 3 N5 X N3 N4 CL = ONE 56
  • 57. CL - QUORUM écriture 57
  • 58. Exemple 1 N0 Client ✓ write N7 N1 OK N6 N2 ✓ N5 N3 RF = 3 ? N4 CL = QUORUM asynchrone 58
  • 59. Exemple 1 (suite) N0 Client ✓ N7 N1 N6 N2 ✓ N5 N3 RF = 3 ✓ N4 CL = QUORUM OK en background... 59
  • 60. Exemple 2 N0 Client ✓ write N7 N1 OK N6 N2 ✓ N5 N3 RF = 3 ? N4 CL = QUORUM asynchrone 60
  • 61. Exemple 2 (suite) N0 Client ✓ N7 N1 N6 N2 ✓ N5 X N3 RF = 3 ? N4 CL = QUORUM KO en background... 61
  • 62. Exemple 3 N0 Client ✓ write N7 N1 KO N6 X N2 ? N5 N3 RF = 3 N4 ? CL = QUORUM asynchrone 62
  • 63. Exemple 4 N0 Client write N7 N1 KO N6 X N2 RF = 3 N5 X N3 N4 CL = QUORUM 63
  • 64. CL - ALL écriture 64
  • 65. Exemple 1 N0 Client ✓ write N7 N1 OK N6 N2 ✓ N5 N3 RF = 3 ✓ N4 CL = ALL 65
  • 66. Exemple 2 N0 Client ✓ write N7 N1 KO N6 X N2 ? N5 N3 RF = 3 ✓ N4 CL = ALL 66
  • 67. Exemple 3 N0 Client write N7 N1 KO N6 X N2 N5 N3 RF = 3 N4 CL = ALL 67
  • 69. Pas de Rollback... • La donnée va être propagée • Mais comment? 69
  • 70. Hinted Handoff N0 ✓ Client write N7 N1 OK N6 N2 ✓ ✓ hint (ttl) N5 RF = 3 X N3 N4 CL = QUORUM asynchrone 70
  • 71. Hinted Handoff N0 ✓ Client write N7 N1 RF = 3 N6 N2 ✓ CL=QUORUM N5 N3 ✓ N4 N3 revient dans le ring 71
  • 72. Hinted Handoff • 1er mécanisme de reprise sur erreur • TTL du hint 72
  • 73. CL - ANY écriture 73
  • 74. Exemple CL Any N0 Client write N7 N1 hint (ttl) Tjs OK! N6 N2 ✓ N5 N3 RF = 3 N4 CL = ANY 74
  • 76. Gossip Protocol N0 N7 N1 N6 X N2 N5 N3 • Pas d’ilots N4 • Découverte du ring • Echange d’info sur le système 76
  • 77. ∿φ Accrual Failure Detector • Ni oui ni non • Probabiliste 77
  • 78. Expiration du hint • Comment synchroniser les données lorsque le noeud revient dans le ring après expiration des hints? 78
  • 79. Anti-Entropy N0 ✓ N7 N1 hint anti-entropy N6 N2 ✓ N5 N3 re pair N4 n ode 2ème mécanisme de reprise sur erreur 79
  • 81. En lecture • Tuneable consistency 81
  • 82. CL - ONE lecture 82
  • 83. Exemple 1 Pourquoi N1 ? N0 Client v2 read N7 N1 re ad digest v1 OK N6 N2 v2 dig est N5 N3 N4 v2 RF = 3 Donnée la plus récente parmi ONE replica CL = ONE 83
  • 84. Exemple 1 (suite) N0 Client v2 N7 N1 N6 read repair N2 v1 => v2 N5 N3 N4 v2 RF = 3 CL = ONE 84
  • 85. Exemple 2 N0 Client v1 read N7 N1 re ad digest v1 OK N6 N2 v1 dig est N5 N3 N4 v2 RF = 3 Donnée la plus récente parmi ONE replica CL = ONE 85
  • 86. Exemple 2 (suite) N0 Client v1 => v2 N7 a ir N1 r ep ad re read repair N6 N2 v1 => v2 N5 N3 N4 v2 RF = 3 CL = ONE 86
  • 87. Read Repair • 3ème mécanisme de reprise sur erreur • Configurable (% de chance) 87
  • 88. CL - QUORUM lecture 88
  • 89. Exemple 1 N0 Client v2 read N7 N1 re ad digest v1 OK N6 N2 + read v2 N5 N3 N4 v2 RF = 3 Donnée la plus récente parmi 2 replicas CL = QUORUM 89
  • 90. Exemple 1 (suite) N0 Client v2 N7 N1 N6 read repair N2 v1 => v2 N5 N3 N4 v2 RF = 3 CL = QUORUM 90
  • 91. Exemple 2 N0 Client v2 read N7 N1 KO N6 X N2 v1 N5 X v2 N3 N4 RF = 3 CL = QUORUM 91
  • 92. CL - ALL lecture 92
  • 93. Exemple 1 N0 Client v2 read N7 N1 re ad digest v2 OK N6 N2 v2 dig est N5 N3 N4 v2 RF = 3 Donnée la plus récente parmi 3 replicas CL = ALL 93
  • 94. Consistence Forte • Comment être certain que la donnée lue est la plus récente? • formule W + R > RF W: nb de replica contactées en écriture R: nb de replica contactées en lecture RF: replication factor • Cas trivial: écriture en ALL et lecture en ONE 94
  • 95. Consistency RF = 3 N0 QUORUM N0 QUORUM N7 N1 N7 N1 Write Write N2 N6 N2 N6 Read Read N5 N3 N5 N3 N4 QUORUM N4 ONE «Weak» «Strong» 95
  • 96. Démo - calculer Token import java.math.BigInteger; public class SimpleTokenCalculator { public static void main(String args[]) { int nbNodes = Integer.parseInt(args[0]); for (int i = 0; i < nbNodes; i++) { BigInteger token = new BigInteger("2"); token = token.pow(127); token = token.multiply(new BigInteger("" + i)); token = token.divide(new BigInteger("" + nbNodes)); System.out.println("token " + i + ": " + token); } } } 96
  • 97. Démo - création KS + CF • create keyspace ks with placement_strategy = 'SimpleStrategy' and strategy_options = {replication_factor:2}; • use ks; • create column family user with key_validation_class = 'AsciiType' and comparator = 'AsciiType' and default_validation_class = 'AsciiType'; • set user['antonio@devoxx.fr']['nom']= 'Goncalves'; • get user['antonio@devoxx.fr']; 97
  • 99. Performance en écriture • En écriture, Cassandra est extrêmement rapide, pourquoi? 99
  • 100. Performance en écriture Mémoire MemTable put ap pe nd Commit Log Fichier 100
  • 101. c1 c2 c3 Mémoire k1 put MemTable ap pe nd - write (k1: c1,c2,c3) Commit Log 101
  • 102. c1 c2 c3 c4 k1 put MemTable ap pe nd - write (k1: c1,c2,c3) - write(k1: c4) Commit Log 102
  • 103. c1 c2 c3 c4 k1 c3 k2 put MemTable ap pe nd - write (k1: c1,c2,c3) - write(k1: c4) - write(k2, c3) Commit Log 103
  • 104. c1 c2 c3 c4 k1 c3 k2 put MemTable ap pe nd - write (k1: c1,c2,c3) - write(k1: c4) - write(k2, c3) - delete(k1,c2) Commit Log 104
  • 105. MemTable drop flush c1 c2 c3 c4 c3 SSTable 1 (read-only) k1 k2 sur disque distinct Commit Log Pourquoi conserver la tombstone? 105
  • 106. Delete distribué • Grace period:10 jours par défaut 106
  • 107. c3 k1 c4 k2 put MemTable ap pe nd - write(k1: c3) k1 c1 c2 c3 c4 k2 c3 SSTable 1 (read-only) - write(k2: c4) Commit Log 107
  • 108. Pas d’update au flush MemTable drop flush c1 c2 c3 c4 c3 SSTable 1 (read-only) k1 k2 c3 c4 k1 k2 SSTable 2 (read-only) Commit Log 108
  • 109. Backups? • SSTables sont readonly.... 109
  • 110. Quid de la lecture? c3 k1 c4 k2 put MemTable ap pe nd - write(k1: c3) c1 c2 c3 c4 c3 SSTable 1 (read-only) k1 k2 - write (k2, c4) c3 c4 k1 k2 SSTable 2 (read-only) Commit Log 110
  • 111. Compaction c3 si < grace period c1 c2 c3 c4 c3 k1 k2 c1 c2 c3 c4 c3 c4 k1 k2 c3 c4 k1 k2 111
  • 112. Lecture MemTable Mémoire Fichiers SSTable SSTable SSTable 6- Contient la valeur... 112
  • 113. Lecture MemTable 1- Pertinent lorsque le client spécifie le nom de la colonne Row Cache Mémoire Fichiers SSTable SSTable SSTable 6- Contient la valeur... 113
  • 114. Lecture MemTable 1- Pertinent lorsque le client spécifie le nom de la colonne Row Cache 2- Stocke l’intégralité d’une row BloomFilter BloomFilter BloomFilter Mémoire Fichiers SSTable SSTable SSTable 6- Contient la valeur... 114
  • 115. Bloom Filter (création) key1 f(key1) g(key1) 115
  • 116. Bloom Filter (création) key2 f(key2) g(key2) 116
  • 117. Bloom Filter (lecture) keyX f(keyX) g(keyX) keyX présent? NON... 117
  • 118. Bloom Filter (lecture) key2 f(key2) g(key2) key2 présent? OUI... vrai positif 118
  • 119. Bloom Filter (lecture) keyY f(keyY) g(keyY) keyY présent? OUI... mais c’est un faux positif 119
  • 120. Lecture MemTable 1- Pertinent lorsque le client spécifie le nom de la colonne Row Cache 2- Stocke l’intégralité d’une row BloomFilter BloomFilter 3- répond à «La SSTable contient-elle un fragment de row ?» BloomFilter Attention, faux positif possible. Key Cache Mémoire Fichiers SSTable SSTable SSTable 6- Contient la valeur... 120
  • 121. Lecture MemTable 1- Pertinent lorsque le client spécifie le nom de la colonne Row Cache 2- Stocke l’intégralité d’une row BloomFilter BloomFilter 3- répond à «La SSTable contient-elle un fragment de row ?» BloomFilter Attention, faux positif possible. Key Cache 4- Donne la position exacte du fragment de row dans la SSTable Mémoire Index Summary Fichiers SSTable SSTable SSTable 6- Contient la valeur... 121
  • 122. Lecture MemTable 1- Pertinent lorsque le client spécifie le nom de la colonne Row Cache 2- Stocke l’intégralité d’une row BloomFilter BloomFilter 3- répond à «La SSTable contient-elle un fragment de row ?» BloomFilter Attention, faux positif possible. Key Cache 4- Donne la position exacte du fragment de row dans la SSTable Mémoire Index Summary 5- Donne la position approximative (intervalle) du fragment de row dans la SSTable Fichiers SSTable SSTable SSTable 6- Contient la valeur... 122
  • 123. Questions? 123
  • 124. Multi Data Center DC USA DC Europe Rack 1 Rack 1 Replica 1 token o token n token s token r Replica 4 token w token v Rack 2 Rack 2 Replica 3 token q token p Replica 2 RF = 4 token u token y token t token x Pas de symétrie entre les DC QUORUM implique nécessairement 2 DC => latence 124
  • 125. DataCenter «Aware» NetworkTopologyStrategy + alternance tokens RF = 3 RF = 3 DC USA DC Europe Rack 1 Rack 1 token n+1 token n token p+1 Replica 4 token p Replica 1 token r+1 Replica 6 token r Replica 3 Rack 2 Rack 2 token o+1 token o token q+1 Replica 5 token q Replica 2 token s+1 token s 125
  • 126. Ring 2 DataCenter (+1) token n token n+1 rack 1 rack 2 token s token s+1 token o token o+1 rack 2 rack 1 token r token r+1 token p token p+1 rack1 rack 2 token q Europe token q+1 USA 126
  • 127. Latence du QUORUM RF = 3 RF = 3 DC USA DC Europe Rack 1 Rack 1 Client ☹ Rack 2 Rack 2 127
  • 128. LOCAL_QUORUM RF = 3 RF = 3 DC USA DC Europe Rack 1 Rack 1 Client ☺ Rack 2 Rack 2 128
  • 129. EACH_QUORUM RF = 3 RF = 3 DC USA DC Europe Rack 1 Rack 1 Client Rack 2 Rack 2 token q token s 129
  • 130. Autres usages Multi DC • 1 DC pour backup • 1 DC pour traitement particulier 130
  • 131. Doubler la taille du cluster 0 t n s o 2*(2^127)/8 r p q 131
  • 132. Doubler la taille du cluster t + n/2 n/2 0 t n (n+o)/2 3*(2^127)/16 (s+t)/2 s o 2*(2^127)/8 = 4*(2^127)/16 (r+s)/2 (o+p)/2 r p q (q+r)/2 (p+q)/2 132
  • 133. Ajouter 1 noeud 0 t n n’’ 2*(2^127)/9 o s r p q On crée un déséquilibre... 133
  • 134. Ajouter 1 noeud 0 0 t’ n’ t n n’’ s’ n’’ o s r’ o’ r p q’ p’ q re-balancing 134
  • 135. Ajout/Retrait/Upgrade • Se font à chaud 135
  • 136. Architecture Interne & Monitoring Stage z evt en sortie Stage y Traitement de l’evt par une thread Stage x (thread pool) les evts font la queue certains peuvent expirer avant d’être traité! SEDA: Staged Event-Driven Architecture... 136
  • 137. Architecture Interne & Monitoring • Monitoring des «stages» cassandra: (‘tp’ pour thread pool) (1) => 1 thread seulement Pool Name Active Pending Completed Blocked All time blocked ReadStage 0 0 1 0 0 RequestResponseStage 0 0 0 0 0 MutationStage 0 0 20 0 0 ReadRepairStage (1) 0 0 0 0 0 ReplicateOnWriteStage 0 0 0 0 0 GossipStage (1) 0 0 86919 0 0 AntiEntropyStage (1) 0 0 0 0 0 MigrationStage (1) 0 0 0 0 0 MemtablePostFlusher 0 0 4 0 0 StreamStage 0 0 0 0 0 FlushWriter 0 0 4 0 0 MiscStage (1) 0 0 0 0 0 InternalResponseStage 0 0 0 0 0 HintedHandoff 0 0 13 0 0 Message type Dropped RANGE_SLICE 0 READ_REPAIR 0 BINARY 0 Messages expirés sont «droppés» READ 0 MUTATION 0 REQUEST_RESPONSE 0 137
  • 138. Une critique... si si • Difficile de rentrer dans le code source 138
  • 139. Une critique... si si • Difficile de rentrer dans le code source 139
  • 140. Questions? 140