Spark Overview / High-level Architecture Indexing from Spark - - PowerPoint PPT Presentation

spark overview high level architecture indexing from
SMART_READER_LITE
LIVE PREVIEW

Spark Overview / High-level Architecture Indexing from Spark - - PowerPoint PPT Presentation

Spark Overview / High-level Architecture Indexing from Spark Reading data from Solr + term vectors & Spark SQL Document Matching user since 2010, committer since April 2014, work for SolrCloud features and bin/solr! Release manager


slide-1
SLIDE 1
slide-2
SLIDE 2

Spark Overview / High-level Architecture Indexing from Spark Reading data from Solr + term vectors & Spark SQL Document Matching

slide-3
SLIDE 3

user since 2010, committer since April 2014, work for SolrCloud features … and bin/solr! Release manager for Lucene / Solr 5.1 in Action Several years experience working with Hadoop, Pig, Hive, , but only started using Spark about 6 months

slide-4
SLIDE 4

Wealth of overview / getting started resources on the Web

https://spark.apache.org/ https://www.cs.berkeley.edu/~matei/papers/2012/nsdi_spark.pdf

Faster, more modernized alternative to MapReduce

Hadoop sorted 100TB in 23 minutes (3x faster than Yahoo’s previous record while using10x

Unified platform for Big Data

Great for iterative algorithms (PageRank, K-Means, Logistic regression) & interactive data mining

slide-5
SLIDE 5

Spark Core Spark SQL Spark Streaming MLlib (machine learning) GraphX (BSP)

Execution Model The Shuffle Caching

slide-6
SLIDE 6

Spark Master (daemon) Spark Slave (daemon)

  • Keeps track of live workers
  • Web UI on port 8080
  • Task Scheduler
  • Restart failed tasks

Spark Executor (JVM process)

Tasks

Spark Worker Node (1...N of these)

Losing a master prevents new applications from being executed Can achieve HA using ZooKeeper and multiple master nodes

slide-7
SLIDE 7

val ¡file ¡= ¡spark.textFile(" val ¡counts ¡= ¡file.flatMap(line ¡=> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡.map(word ¡=> ¡(word, ¡1)

slide-8
SLIDE 8

Split lines into words Map words into pairs with count of 1

map(word ¡=> ¡(word, ¡1)) ¡

quick ¡ brown ¡ fox ¡ (quick,1) ¡ (brown,1) ¡ (fox,1) ¡ quick ¡ (quick,1) ¡ quick ¡ (quick,1) ¡

… ¡ … ¡

x

slide-9
SLIDE 9

Created from external system OR using a transformation of another RDD lineage of coarse-grained transformations (map, join, filter, is lost, RDDs can be re-computed by re-playing the transformations User can choose to persist an RDD (for reusing during interactive data-mining)

slide-10
SLIDE 10

https://github.com/LucidWorks/spark-solr/ Streaming applications

Real-time, streaming ETL jobs as sink for Spark job Real-time document matching against stored queries

Distributed computations (interactive data mining, machine learning)

Solr query as Spark RDD (resilient distributed dataset) Optionally process results from each shard in parallel

slide-11
SLIDE 11

Transform a stream of records into small, deterministic batches

Discretized stream: sequence of RDDs Once you have an RDD, you can use all the other Spark libs (MLlib, etc) Low-latency micro batches Time to process a batch must be less than the batch interval time

Two types of operators:

Transformations (group by, join, etc) Output (send to some external sink, e.g. Solr)

Impressive performance!

slide-12
SLIDE 12

zkHost ¡localhost:2181 ¡–collection ¡social ¡

<Status> tweets = jssc, null, filters); Various transformations / enrichments

  • n each tweet (e.g. sentiment analysis,

language detection) JavaDStream<SolrInputDocument> docs = tweets.map

map()

SolrSupport.indexDStreamOfDocs

slide-13
SLIDE 13

<Status> ¡tweets ¡= ¡ createStream(jssc, ¡null, ¡filters); ¡ // ¡map ¡incoming ¡tweets ¡into ¡SolrInputDocument ¡objects ¡for ¡indexing ¡in ¡Solr SolrInputDocument> ¡docs ¡= ¡tweets.map( ¡ Status,SolrInputDocument>() ¡{ ¡ SolrInputDocument ¡call(Status ¡status) ¡{ ¡ ¡doc ¡= ¡ autoMapToSolrInputDoc("tweet-­‑"+status.getId(), ¡status, ¡ provider_s", ¡"twitter"); ¡ author_s", ¡status.getUser().getScreenName()); ¡ ", ¡status.isRetweet() ¡? ¡"echo" ¡: ¡"post"); ¡

slide-14
SLIDE 14

> ¡docs) ¡ SolrInputDocument>, ¡Void>() ¡{ ¡ SolrInputDocument> ¡solrInputDocumentJavaRDD) ¡throws ¡Exception ¡{ ¡ solrInputDocumentJavaRDD.foreachPartition( ¡ <Iterator<SolrInputDocument>>() ¡{ ¡ (Iterator<SolrInputDocument> ¡solrInputDocumentIterator) ¡throws ¡Exception ¡{ ¡ solrServer ¡= ¡getSolrServer(zkHost); ¡ SolrInputDocument> ¡batch ¡= ¡new ¡ArrayList<SolrInputDocument>(); ¡ solrInputDocumentIterator.hasNext()) ¡{ ¡ solrInputDocumentIterator.next()); ¡ () ¡>= ¡batchSize) ¡ sendBatchToSolr(solrServer, ¡collection, ¡batch); ¡ batch.isEmpty()) ¡ (solrServer, ¡collection, ¡batch); ¡

slide-15
SLIDE 15

For each document, determine which of a large set of stored queries Useful for alerts, alternative flow paths through a stream, etc Index a micro-batch into an embedded (in-memory) Solr instance and then determine which queries match Matching framework; you have to decide where to load the stored queries from and what to do when matches are found Scale it using Spark … need to scale to many queries, checkout

slide-16
SLIDE 16

map()

= , null, filters); JavaDStream<SolrInputDocument> docs = tweets.map( new Function<Status,SolrInputDocument>() { JavaDStream<SolrInputDocument> enriched = SolrSupport.filterDocuments(docFilterContext

Get queries

Index docs into an EmbeddedSolrServer Initialized from configs stored in ZooKeeper

slide-17
SLIDE 17

Custom partitioning scheme for RDD using Solr’s DocRouter Stream docs directly to each shard leader using metadata from document shard assignment, and ConcurrentUpdateSolrClient

shardPartitioner ¡= ¡new ¡ShardPartitioner(zkHost, ¡collection); ¡ shardPartitioner).foreachPartition( ¡ <Iterator<Tuple2<String, ¡SolrInputDocument>>>() ¡{ ¡ call(Iterator<Tuple2<String, ¡SolrInputDocument>> ¡tupleIter) ¡ ConcurrentUpdateSolrClient ¡cuss ¡= ¡null; ¡ tupleIter.hasNext()) ¡{ ¡ ConcurrentUpdateSolrClient ¡once ¡per ¡partition ¡

slide-18
SLIDE 18

Can execute any query and expose as an RDD produces JavaRDD<SolrDocument> ¡ Use deep-paging if needed (cursorMark) For reading full result sets where global sort order doesn’t matter, parallelize query execution by distributing requests across the Spark

SolrDocument> ¡results ¡= ¡ ¡ solrRDD.queryShards(jsc, ¡solrQuery); ¡

slide-19
SLIDE 19

Can be used to construct RDD<Vector> which can then be passed to

new ¡SolrRDD(zkHost, ¡collection); ¡ <Vector> ¡vectors ¡= ¡ ¡ solrRDD.queryTermVectors(jsc, ¡solrQuery, ¡field, ¡numFeatures ¡clusters ¡= ¡ ¡ vectors.rdd(), ¡numClusters, ¡numIterations);

slide-20
SLIDE 20

new ¡SolrQuery(...); ¡ "text_t","type_s"); ¡ SolrRDD(zkHost, ¡collection); ¡ solrJavaRDD ¡= ¡solrRDD.queryShards(jsc, ¡solrQuery); ¡ new ¡SQLContext(jsc); ¡ sqlContext, ¡solrQuery, ¡solrJavaRDD, ¡zkHost, ¡collection); ¡ "tweets"); ¡ "SELECT ¡COUNT(type_s) ¡FROM ¡tweets ¡WHERE ¡type_s='echo'" results.javaRDD().map(new ¡Function<Row, ¡Long>() ¡{ ¡ Long ¡call(Row ¡row) ¡{ ¡

slide-21
SLIDE 21

Reference implementation of Solr and Spark on YARN Formal benchmarks for reads and writes to Solr

Checkout SOLR-6816 – improving replication performance

Add Spark support to Solr Scale Toolkit Integrate metrics to give visibility into performance More use cases … Feel free to reach out to me with questions:

slide-22
SLIDE 22