1. Cassandra et Spark Streaming
Architecture événementielle et Analytique temps réel
Victor Coustenoble Petit Déjeuner OCTO Technology
Ingénieur Solutions 14/04/15
victor.coustenoble@datastax.com
@vizanalytics
3. 3
DataStax délivre une plateforme de la base de données
Apache Cassandra, conçue spécifiquement pour les
besoins en Performance et Disponibilité exigés par les
applications d’Internet des Objets, Web ou Mobiles, en
offrant aux entreprises une base de données Sécurisée
toujours disponible, qui reste Simple à administrer même
pour des déploiements à grande échelle, dans un seul ou
de Multiples Data Centers et dans le Cloud.
5. DataStax
Fondé en avril 2010
~35 500+
Santa Clara, Austin, New York, London, Paris, Sydney
400+
Employés Pourcent Clients
5
6. Straightening the road
RELATIONAL DATABASES
CQL SQL
OpsCenter / DevCenter Management tools
DSE for search & analytics Integration
Security Security
Support, consulting & training 30 years ecosystem
7. • Sans Maître-Esclave (peer-to-peer), sans Point Unique de Défaillance (No SPOF)
• Distribuée avec la possibilité de Data Center
• 100% Disponible (replication)
• Massivement scalable
• Montée en charge linéaire
• Haute Performance (lecture ET écriture)
• Multi Data Center
• Séries Temporelles
• Multi Modèle
• Simple à Exploiter
• Language CQL (comme SQL)
• Outils OpsCenter / DevCenter
Apache Cassandra™
7
9. DataStax Enterprise
DataStax supporte la communauté open source et les entreprises
9
Open Source/Communauté Enterprise Software
• DataStax emploie le président du
projet Apache et développe 80+% du
code de Apache Cassandra
• DataStax Community Edition
• DataStax Simple OpsCenter
• DataStax DevCenter
• DataStax Drivers/Connecteurs
• Documentation en ligne
• Formation en ligne
• Mailing lists et forums
• DataStax Enterprise Edition
• Cassandra Certifié
• In-Memory
• Analytique intégré (Hadoop, Spark)
• Recherche intégrée (Solr)
• Securité d’entreprise
• DataStax OpsCenter Avancé
• Services d’Administration Automatique
• Support Expert
• Aide et Consulting
• Formation Professionnelle
12. Cassandra a besoin d’un framework de traitement distribué
Pour des requêtes indépendates du modèle de données
Pour des opérations cross-table (JOIN, UNION)
Pour des analyses complexes (machine learning)
Pour des transformation, des aggrégations
Pour des traitements de flux
…
14. Cas d’utilisation de Spark pour Cassandra
14
Load data from various
sources
Analytics (join, aggregate, transform, …)
Sanitize, validate, normalize data
Schema migration,
Data conversion
19. Connecteur Cassandra Spark
•Tables Cassandra tables exposées en temps que RDDs Spark
•Chargement des données depuis Cassandra vers Spark
•Ecriture des données depuis Spark vers Cassandra
•Object mapper : Mapping des tables Cassandra en objets Scala/Java
•Conversions des types Cassandra en type Scala/Java
•Sélection et filtres des données au niveau de Cassandra
•API Scala, Java et Pyhton
20. Lecture des données
val table_rdd = sc
.cassandraTable[CassandraRow]("db", "tweets")
.select("user_name", "message")
.where("user_name = ?", "ewa")
row
representation keyspace table
server side column
and row selection
21. Ecriture des données
CREATE TABLE test.words(word TEXT PRIMARY KEY, count INT);
val collection_rdd = sc.parallelize(Seq(("foo", 2), ("bar", 5)))
collection_rdd.saveToCassandra("test", "words", SomeColumns("word", "count"))
cqlsh:test> select * from words;
word | count
------+-------
bar | 5
foo | 2
(2 rows)
22. “Je veux des résultats en continue depuis un flux de données”
“Je veux une garantie que mes messages soient traités une seule fois”
DStream (Discretized Stream)
Flux continu de micro batchs pour:
• Traitements complexes avec un minimal d’effort
• Calculs sur des flux dans un petit interval de temps
Une transformation sur DStream = transformations sur ses RDDs
Quand le batch n’est plus suffisant
23. Spark Streaming Input
Données en entrée depuis:
• une socket TCP
• des messages depuis Kafka
• des logs depuis Flume
• des fichiers depuis HDFS (monitorer la création de
nouveaux fichiers)
• une file MQ (type ZeroMQ)
• des tweets depuis Twitter (API Twitter4J)
• …
24. Utilisation de Spark Streaming
L’API de Spark Streaming est
identique à l’API classique de Spark
=> Des portions de code batch et de
flux peuvent être partagés
import com.datastax.spark.connector.streaming._
// Spark connection options
val conf = new SparkConf(true)...
// streaming with 1 second batch window
val ssc = new StreamingContext(conf, Seconds(1))
// stream input
val lines = ssc.socketTextStream(serverIP, serverPort)
// count words
val wordCounts = lines.flatMap(_.split(" ")).map(word =>
(word, 1)).reduceByKey(_ + _)
// stream output
wordCounts.saveToCassandra("test", "words")
// start processing
ssc.start()
ssc.awaitTermination()
27. “Pour du calcul de prévisions, j’ai besoin d’un accès rapide à
mes données historiques couplé à des données en temps réel
provenant d’un flux”
28. Architecture Lambda
Une architecture de traitement de données conçue pour gérer des énormes
quantités de données en tirant avantage à la fois des méthodes de traitement batch
et des traitements de flux.
30. Confidential 30
Applications Capteurs Web Mobiles
Détection
d’intrusion
Détection de
panne
Analyse de
navigation
Analyse de
métriques
réseaux
Détection de
fraude
Optimisation
dynamique de
processus
Recommandatio
ns
Publicité
géolocalisée
Traitement de Log
Planning de
logistique
Analyse de
sentiment
Analyse et traitement temps réel
Key Takeaway-
Introduce the company, our incredible growth and global presence, that we are in about 25% of the FORTUNE 100, and the fact that many of the online and mobile applications you already use every day are actually built on DataStax.
Talk Track-
DataStax, the leading distributed database technology, delivers Apache Cassandra to the world’s most innovative companies such as Netflix, Rackspace, Pearson Education and Constant Contact. DataStax is built to be agile, always-on, and predictably scalable to any size.
We were founded in April 2010, so we are a little over 4 years old. We are headquartered in Santa Clara, California and have offices in Austin TX, New York, London, England and Sydney Australia. We now have over 330 employees; this number will reach well over 400 by the end of our fiscal year (Jan 31 2015) and double by the end of FY16.
Currently 25% of the Fortune 100 use us, and our success has been built on our customers success and today and we have over 500 customers worldwide, in over 40 countries. The logos you see here are ones that you are already using every day.
These applications are all built on DataStax and Apache Cassandra.
So how have we come so far in such a short time…..?
En fait la mission de DataStax est de vos libérer de ces incertitudes et vous faciliter la route sur cette nouvelle voie.
A cette fin, nous vous offrons un DML DDL appelé CQL très proche du SQL maitrisé par vos équipes, des outils complets d’administration et de monitoring,
So, What DataStax is doing is trying to straightened that bend in the road. We are providing things like CQL, and management tools called DevCenter and OpsCenter. DataStax Enterprise provides integration into analytics and search capabilities and we do it all within a secure environment. We also provide consultants and training courses, including free virtual training to help get you up to speed.
Cassandra is designed to handle big data workloads across multiple data centers with no single point of failure, providing enterprises with continuous availability without compromising performance.
It uses aspects of Dynamos partitioning and replication and a log-structured data model similar to Bigtable’s.
It takes its distribution algorithm from Dynamo and its data model from Bigtable.
Cassandra is a reinvented database which is lightening fast and always on ideal for todays online applications where relational databases like Oracle can’t keep up.
This means that in todays world, cassandra stores and processes real time information at fast, predictive performance and built in fault tolerance
DataStax is the company that delivers Cassandra to the enterprise.
First, we take the open source software and put it through rigorous quality assurance tests including a 1000 node scalability test.
We certify it and provide the worlds most comprehensive support, training and consulting for Cassandra so that you can get up and running quickly.
But that isn’t all DataStax does.
We also build additional software features on top of DataStax including security, search, analytics as well as provide in memory capabilities that don’t come with the open source Cassandra product.
We also provide management services to help visualize your nodes, plan your capacity and repair issues automatically.
Finally, we also provide developer tools and drivers as well as monitoring tools. DataStax is the commercial company behind Apache Cassandra plus a whole host of additional software and services.
Predictive analytics
Does this simple architecture look familiar to you? Lambda
Nathan Marz
DUYHAI
Shark is hive compatible – you can run the same application on Shark
Shark integration is only on DSE, otherwise you have to wait for Spark SQL
Separate projects – Spark is totally different project
Spark SQL has borrowed from Spark
Both promising to be Hive compatible
Predictive analytics
Does this simple architecture look familiar to you? Lambda
Nathan Marz