Top Banner
Introduction à Cassandra Big data & NoSQL 1 / 35
35

Introduction à Cassandra

Aug 08, 2015

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction à Cassandra

Introduction à CassandraBig data & NoSQL

1 / 35

Page 2: Introduction à Cassandra

1.  Big Data2.  NoSQL3.  Architecture de Cassandra4.  Développer avec CQL

Objectifs

2 / 35

Page 3: Introduction à Cassandra

Big DataBig data is high­volume, high­velocity and high­variety informationassets that demand cost­effective, innovative forms of informationprocessing for enhanced insight and decision making.

Gartner

3 / 35

Page 4: Introduction à Cassandra

Big DataTraitements en Batch ou FluxForts volumesPerformancesHaute­disponibilité

4 / 35

Page 5: Introduction à Cassandra

SQL or NoSQL?Not using the relational model (nor the SQL language).Open source.Designed to run on large clustersBased on the needs of 21st century web propertiesNo schema, allowing fields to be added to any record without controls

http://martinfowler.com/bliki/NosqlDefinition.html

5 / 35

Page 6: Introduction à Cassandra

Relationnel

Clé­Valeur

Document

Colonnes Cassandra

Graphe

Mixte

Modèles de données

6 / 35

Page 7: Introduction à Cassandra

ACID

AtomicityCohérenceIsolationDurability

BASE

Basically AvailableSoft stateEventual consistency

ACID ou BASE?

7 / 35

Page 8: Introduction à Cassandra

ConsistencyAvailabilityPartition tolerance

CAP

8 / 35

Page 9: Introduction à Cassandra

CAP

9 / 35

Page 10: Introduction à Cassandra

Cassandra en résuméDistribuéeMasterless: pas de SPOFScalabilité linéaireTolérance aux pannes: 100% uptimePerformancesConsistance réglableMulti­datacenterSimplicité opérationnelle

10 / 35

Page 11: Introduction à Cassandra

Les origines

11 / 35

Page 12: Introduction à Cassandra

Plage de Tokens

Distribution

12 / 35

Page 13: Introduction à Cassandra

Hachage consistant

Distribution

13 / 35

Page 14: Introduction à Cassandra

Réplication

14 / 35

Page 15: Introduction à Cassandra

Scalabilité

15 / 35

Page 16: Introduction à Cassandra

Scalabilité linéaire

http://techblog.netflix.com/2011/11/benchmarking­cassandra­scalability­on.html

16 / 35

Page 17: Introduction à Cassandra

Noeuds virtuels

17 / 35

Page 18: Introduction à Cassandra

Node∈Rack∈DatacenterDecoupage

GéographiqueLogique

Cloud

Multi-datacenter

18 / 35

Page 19: Introduction à Cassandra

Coordinateur

19 / 35

Page 20: Introduction à Cassandra

Timestamp par cellule

Consistance ALL: Ecriture

20 / 35

Page 21: Introduction à Cassandra

Tolérance aux pannes

Hinted Handoff

Consistance ONE: Ecriture

21 / 35

Page 22: Introduction à Cassandra

Last write wins

Read repair

Consistance ALL: Lecture

22 / 35

Page 23: Introduction à Cassandra

Eventual consistency

Consistance ONE: Lecture

23 / 35

Page 24: Introduction à Cassandra

Consistance réglableNiveau de consistance par requête

24 / 35

Page 25: Introduction à Cassandra

Consistance immédiate

R + W > RF

Consistance au final

R + W ≤ RF

Consistance: le bilan

25 / 35

Page 26: Introduction à Cassandra

Pour l'écritureAppend only + compactionPas de disk seek

Pour la lectureRéplication & Load balancingModélisation adaptée → AccèsdirectCaches par table

Performances

26 / 35

Page 27: Introduction à Cassandra

Simplicité opérationnelleInstallation

Linux, Java, Python, NTPPackaging: .tar, .rpm, .deb, .exe2­3 fichiers de configuration1 seul processus1 seul type de noeud

Monitoringnodetool, JMX, OpsCenter

27 / 35

Page 28: Introduction à Cassandra

Simplicité pour le développementCQL = SQL simplifiécqlshDevCenterCCM, un cluster en local

28 / 35

Page 29: Introduction à Cassandra

CQLCREATE TABLE utilisateur( id_utilisateur UUID, login VARCHAR, date_naissance TIMESTAMP, roles SET<VARCHAR>, PRIMARY KEY (id_utilisateur));

INSERT INTO utilisateur(id_utilisateur, login, date_naissance, roles) VALUES ('abc123...', 'jdoe', '1978-04-06',{'blogger','journaliste'});

SELECT * FROM utilisateur WHERE id_utilisateur='abc123...';

29 / 35

Page 30: Introduction à Cassandra

Modèle orienté colonne

Table utilisateur 

30 / 35

Page 31: Introduction à Cassandra

CQL Grandes lignesCREATE TABLE message( id_utilisateur UUID, id_message TIMEUUID, message VARCHAR, PRIMARY KEY (id_utilisateur, id_message));

INSERT INTO message(id_utilisateur, id_message) VALUES ('abc123...', now(),'Vive Cassandra');

SELECT * FROM utilisateur WHERE id_utilisateur='abc123...';SELECT message FROM utilisateur WHERE id_utilisateur='abc123...' AND id_message='cde456...';

31 / 35

Page 32: Introduction à Cassandra

Modèle orienté colonne

Table utilisateur 

Table message 

Map<RowKey, SortedMap<ColumnKey, ColumnValue>>

32 / 35

Page 33: Introduction à Cassandra

ModélisationDénormaliser!Besoin → Requête → TableAdapter les données aux requêtes (pas l'inverse)

33 / 35

Page 34: Introduction à Cassandra

Driver

Load balancing, tolérance aux pannes, découverteSynchrone ou asynchrone (réactive programming)Librairies Java:

ObjectMapper, Achilles, Spring Data Cassandra...Cassandra Unit, Stubbed Cassandra

34 / 35

Page 35: Introduction à Cassandra

Questions

35 / 35