Data at the Speed of your Users
Apache Cassandra and Spark for simple, distributed, near real-time stream processing.
GOTO Copenhagen 2014
Data at the Speed of your Users Apache Cassandra and Spark for - - PowerPoint PPT Presentation
Data at the Speed of your Users Apache Cassandra and Spark for simple, distributed, near real-time stream processing. GOTO Copenhagen 2014 Rustam Aliyev Solution Architect at . @rstml Big Data? Photo:
Apache Cassandra and Spark for simple, distributed, near real-time stream processing.
GOTO Copenhagen 2014
Solution Architect at .
Collection Processing Storing Delivery
Collection
Delivery
Distributed Database
Photo: Flickr / Hypostyle Hall / Jorge LáscarCell 1 Cell 2 … Cell 3 Partition Key
Android storage: 32GB version: 4.4 weight: 130g
sort order on disk
Nexus 5
Android storage: 32GB version: 4.4 weight: 130g Nexus 5
iOS storage: 64GB version: 8.0 weight: 129g iPhone 6
memory: version: weight: Other
0000 8000 4000 C000 2000 6000 E000 A000 3D97 Nexus 5
0000 8000 4000 C000 2000 6000 E000 A000 9C4F iPhone 6
3D97
0000 8000 4000 C000 2000 6000 E000 A000
3D97 9C4F
0000 8000 4000 C000 2000 6000 E000 A000
3D97 9C4F 9C4F 3D97
Distributed Data Processing Engine
Photo: Flickr / Sparklers / Alexandra Compo / CreativeCommonsLogistic Regression
Running Time (s) 1000 2000 3000 4000 Number of Iterations 1 5 10 20 30
Spark Hadoop
map
map filter groupBy sort union join leftOuterJoin rightOuterJoin reduce count fold reduceByKey groupByKey cogroup cross zip sample take first partitionBy mapWith pipe save ...
Resilient Distributed Datasets
Node 1 Node 2 Node 3 Node 1 Node 2 Node 3
groupBy join filter map
Disk RDD Memory RDD
RDD
DStream Data Stream
https://github.com/datastax/spark-cassandra-connector
M M M
Cassandra Spark Worker Spark Master & Worker
ALL: 7139 2014-09-21: 220 2014-09-20: 309 2014-09-19: 129
sort order
#hashtag
CREATE ¡TABLE ¡hashtags ¡( ¡ ¡ ¡ ¡ ¡hashtag ¡text, ¡ ¡ ¡ ¡ ¡interval ¡text, ¡ ¡ ¡ ¡ ¡mentions ¡counter, ¡ ¡ ¡ ¡ ¡PRIMARY ¡KEY((hashtag), ¡interval) ¡ ) ¡WITH ¡CLUSTERING ¡ORDER ¡BY ¡(interval ¡DESC); ¡
import ¡com.datastax.spark.connector.streaming._ ¡
¡ ¡.setMaster("spark://127.0.0.1:7077") ¡ ¡ ¡.setAppName("Twitter-‑Demo") ¡ ¡ ¡.setJars("demo-‑assembly-‑1.0.jar")) ¡ ¡ ¡.set("spark.cassandra.connection.host", ¡"127.0.0.1") ¡
¡ ¡createStream(ssc, ¡None, ¡Nil, ¡storageLevel ¡= ¡StorageLevel.MEMORY_ONLY_SER_2) ¡
¡ ¡tweet.getText.toLowerCase.split(" ¡"). ¡ ¡ ¡filter(tags.contains(Seq("#iphone", ¡"#android")))) ¡
¡ case ¡(tag, ¡mentions) ¡=> ¡(tag, ¡mentions, ¡"ALL") ¡ } ¡
import ¡com.datastax.spark.connector.streaming._ ¡
¡ ¡.setMaster("spark://127.0.0.1:7077") ¡ ¡ ¡.setAppName("Twitter-‑Demo") ¡ ¡ ¡.setJars("demo-‑assembly-‑1.0.jar")) ¡ ¡ ¡.set("spark.cassandra.connection.host", ¡"127.0.0.1") ¡
¡ ¡createStream(ssc, ¡None, ¡Nil, ¡storageLevel ¡= ¡StorageLevel.MEMORY_ONLY_SER_2) ¡
¡ ¡tweet.getText.toLowerCase.split(" ¡"). ¡ ¡ ¡filter(tags.contains(Seq("#iphone", ¡"#android")))) ¡
¡ case ¡(tag, ¡mentions) ¡=> ¡(tag, ¡mentions, ¡"ALL") ¡ } ¡
import ¡com.datastax.spark.connector.streaming._ ¡
¡ ¡.setMaster("spark://127.0.0.1:7077") ¡ ¡ ¡.setAppName("Twitter-‑Demo") ¡ ¡ ¡.setJars("demo-‑assembly-‑1.0.jar")) ¡ ¡ ¡.set("spark.cassandra.connection.host", ¡"127.0.0.1") ¡
¡ ¡createStream(ssc, ¡None, ¡Nil, ¡storageLevel ¡= ¡StorageLevel.MEMORY_ONLY_SER_2) ¡
¡ ¡tweet.getText.toLowerCase.split(" ¡"). ¡ ¡ ¡filter(tags.contains(Seq("#iphone", ¡"#android")))) ¡
¡ case ¡(tag, ¡mentions) ¡=> ¡(tag, ¡mentions, ¡"ALL") ¡ } ¡
¡ ¡createStream(ssc, ¡None, ¡Nil, ¡storageLevel ¡= ¡StorageLevel.MEMORY_ONLY_SER_2) ¡
¡ ¡tweet.getText.toLowerCase.split(" ¡"). ¡ ¡ ¡filter(tags.contains(Seq("#iphone", ¡"#android")))) ¡
¡ case ¡(tag, ¡mentions) ¡=> ¡(tag, ¡mentions, ¡"ALL") ¡ } ¡
¡ "demo_ks", ¡"hashtags", ¡Seq("hashtag", ¡"mentions", ¡"interval")) ¡
ssc.awaitTermination() ¡
¡ ¡createStream(ssc, ¡None, ¡Nil, ¡storageLevel ¡= ¡StorageLevel.MEMORY_ONLY_SER_2) ¡
¡ ¡tweet.getText.toLowerCase.split(" ¡"). ¡ ¡ ¡filter(tags.contains(Seq("#iphone", ¡"#android")))) ¡
¡ case ¡(tag, ¡mentions) ¡=> ¡(tag, ¡mentions, ¡DateTime.now.toString("yyyyMMdd")) ¡ } ¡
¡ "demo_ks", ¡"hashtags", ¡Seq("hashtag", ¡"mentions", ¡"interval")) ¡
ssc.awaitTermination() ¡
¡ ¡createStream(ssc, ¡None, ¡Nil, ¡storageLevel ¡= ¡StorageLevel.MEMORY_ONLY_SER_2) ¡
¡ ¡tweet.getText.toLowerCase.split(" ¡"). ¡ ¡ ¡filter(tags.contains(Seq("#iphone", ¡"#android")))) ¡
¡ case ¡(tag, ¡mentions) ¡=> ¡(tag, ¡mentions, ¡"ALL") ¡ } ¡
¡ "demo_ks", ¡"hashtags", ¡Seq("hashtag", ¡"mentions", ¡"interval")) ¡
ssc.awaitTermination() ¡