+ All Categories
Home > Documents > Parallel Processing MapReduce, FlumeJava and Dryad

Parallel Processing MapReduce, FlumeJava and Dryad

Date post: 19-Nov-2021
Category:
Upload: others
View: 12 times
Download: 0 times
Share this document with a friend
89
Parallel Processing MapReduce, FlumeJava and Dryad Amir H. Payberah [email protected] KTH Royal Institute of Technology Amir H. Payberah (KTH) Parallel Processing 2016/09/12 1 / 72
Transcript
Page 1: Parallel Processing MapReduce, FlumeJava and Dryad

Parallel ProcessingMapReduce, FlumeJava and Dryad

Amir H. [email protected]

KTH Royal Institute of Technology

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 1 / 72

Page 2: Parallel Processing MapReduce, FlumeJava and Dryad

What do we do when there is too much data toprocess?

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 2 / 72

Page 3: Parallel Processing MapReduce, FlumeJava and Dryad

Scale Up vs. Scale Out (1/2)

I Scale up or scale vertically: adding resources to a single node in asystem.

I Scale out or scale horizontally: adding more nodes to a system.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 3 / 72

Page 4: Parallel Processing MapReduce, FlumeJava and Dryad

Scale Up vs. Scale Out (2/2)

I Scale up: more expensive than scaling out.

I Scale out: more challenging for fault tolerance and software devel-opment.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 4 / 72

Page 5: Parallel Processing MapReduce, FlumeJava and Dryad

Taxonomy of Parallel Architectures

DeWitt, D. and Gray, J. “Parallel database systems: the future of high performance database systems”. ACMCommunications, 35(6), 85-98, 1992.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 5 / 72

Page 6: Parallel Processing MapReduce, FlumeJava and Dryad

Taxonomy of Parallel Architectures

DeWitt, D. and Gray, J. “Parallel database systems: the future of high performance database systems”. ACMCommunications, 35(6), 85-98, 1992.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 5 / 72

Page 7: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 6 / 72

Page 8: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce

I A shared nothing architecture for processing large data sets with aparallel/distributed algorithm on clusters of commodity hardware.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 7 / 72

Page 9: Parallel Processing MapReduce, FlumeJava and Dryad

Challenges

I How to distribute computation?

I How can we make it easy to write distributed programs?

I Machines failure.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 8 / 72

Page 10: Parallel Processing MapReduce, FlumeJava and Dryad

Idea

I Issue:• Copying data over a network takes time.

I Idea:• Bring computation close to the data.• Store files multiple times for reliability.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 9 / 72

Page 11: Parallel Processing MapReduce, FlumeJava and Dryad

Idea

I Issue:• Copying data over a network takes time.

I Idea:• Bring computation close to the data.• Store files multiple times for reliability.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 9 / 72

Page 12: Parallel Processing MapReduce, FlumeJava and Dryad

Simplicity

I Don’t worry about parallelization, fault tolerance, data distribution,and load balancing (MapReduce takes care of these).

I Hide system-level details from programmers.

Simplicity!

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 10 / 72

Page 13: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Definition

I A programming model: to batch process large data sets (inspiredby functional programming).

I An execution framework: to run parallel algorithms on clusters ofcommodity hardware.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 11 / 72

Page 14: Parallel Processing MapReduce, FlumeJava and Dryad

Programming Model

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 12 / 72

Page 15: Parallel Processing MapReduce, FlumeJava and Dryad

Warmup Task

I We have a huge text document.

I Count the number of times each distinct word appears in the file

I If the file fits in memory: words(doc.txt) | sort | uniq -c

I If not?

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 13 / 72

Page 16: Parallel Processing MapReduce, FlumeJava and Dryad

Warmup Task

I We have a huge text document.

I Count the number of times each distinct word appears in the file

I If the file fits in memory: words(doc.txt) | sort | uniq -c

I If not?

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 13 / 72

Page 17: Parallel Processing MapReduce, FlumeJava and Dryad

Warmup Task

I We have a huge text document.

I Count the number of times each distinct word appears in the file

I If the file fits in memory: words(doc.txt) | sort | uniq -c

I If not?

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 13 / 72

Page 18: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Programming Model

I words(doc.txt) | sort | uniq -c

I Sequentially read a lot of data.

I Map: extract something you care about.

I Group by key: sort and shuffle.

I Reduce: aggregate, summarize, filter or transform.

I Write the result.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 14 / 72

Page 19: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Programming Model

I words(doc.txt) | sort | uniq -c

I Sequentially read a lot of data.

I Map: extract something you care about.

I Group by key: sort and shuffle.

I Reduce: aggregate, summarize, filter or transform.

I Write the result.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 14 / 72

Page 20: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Programming Model

I words(doc.txt) | sort | uniq -c

I Sequentially read a lot of data.

I Map: extract something you care about.

I Group by key: sort and shuffle.

I Reduce: aggregate, summarize, filter or transform.

I Write the result.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 14 / 72

Page 21: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Programming Model

I words(doc.txt) | sort | uniq -c

I Sequentially read a lot of data.

I Map: extract something you care about.

I Group by key: sort and shuffle.

I Reduce: aggregate, summarize, filter or transform.

I Write the result.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 14 / 72

Page 22: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Programming Model

I words(doc.txt) | sort | uniq -c

I Sequentially read a lot of data.

I Map: extract something you care about.

I Group by key: sort and shuffle.

I Reduce: aggregate, summarize, filter or transform.

I Write the result.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 14 / 72

Page 23: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Programming Model

I words(doc.txt) | sort | uniq -c

I Sequentially read a lot of data.

I Map: extract something you care about.

I Group by key: sort and shuffle.

I Reduce: aggregate, summarize, filter or transform.

I Write the result.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 14 / 72

Page 24: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Dataflow

I map function: processes data and generates a set of intermediatekey/value pairs.

I reduce function: merges all intermediate values associated with thesame intermediate key.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 15 / 72

Page 25: Parallel Processing MapReduce, FlumeJava and Dryad

Word Count in MapReduce

I Consider doing a word count of the following file using MapReduce:

Hello World Bye World

Hello Hadoop Goodbye Hadoop

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 16 / 72

Page 26: Parallel Processing MapReduce, FlumeJava and Dryad

Word Count in MapReduce - map

I The map function reads in words one a time and outputs (word, 1)for each parsed input word.

I The map function output is:

(Hello, 1)

(World, 1)

(Bye, 1)

(World, 1)

(Hello, 1)

(Hadoop, 1)

(Goodbye, 1)

(Hadoop, 1)

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 17 / 72

Page 27: Parallel Processing MapReduce, FlumeJava and Dryad

Word Count in MapReduce - shuffle

I The shuffle phase between map and reduce phase creates a list ofvalues associated with each key.

I The reduce function input is:

(Bye, (1))

(Goodbye, (1))

(Hadoop, (1, 1))

(Hello, (1, 1))

(World, (1, 1))

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 18 / 72

Page 28: Parallel Processing MapReduce, FlumeJava and Dryad

Word Count in MapReduce - reduce

I The reduce function sums the numbers in the list for each key andoutputs (word, count) pairs.

I The output of the reduce function is the output of the MapReducejob:

(Bye, 1)

(Goodbye, 1)

(Hadoop, 2)

(Hello, 2)

(World, 2)

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 19 / 72

Page 29: Parallel Processing MapReduce, FlumeJava and Dryad

Combiner Function (1/2)

I In some cases, there is significant repetition in the intermediate keysproduced by each map task, and the reduce function is commutativeand associative.

Machine 1:(Hello, 1)

(World, 1)

(Bye, 1)

(World, 1)

Machine 2:(Hello, 1)

(Hadoop, 1)

(Goodbye, 1)

(Hadoop, 1)

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 20 / 72

Page 30: Parallel Processing MapReduce, FlumeJava and Dryad

Combiner Function (2/2)

I Users can specify an optional combiner function to merge partiallydata before it is sent over the network to the reduce function.

I Typically the same code is used to implement both the combinerand the reduce function.

Machine 1:(Hello, 1)

(World, 2)

(Bye, 1)

Machine 2:(Hello, 1)

(Hadoop, 2)

(Goodbye, 1)

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 21 / 72

Page 31: Parallel Processing MapReduce, FlumeJava and Dryad

Example: Word Count - map

public static class MyMap extends Mapper<...> {

private final static IntWritable one = new IntWritable(1);

private Text word = new Text();

public void map(LongWritable key, Text value, Context context)

throws IOException, InterruptedException {

String line = value.toString();

StringTokenizer tokenizer = new StringTokenizer(line);

while (tokenizer.hasMoreTokens()) {

word.set(tokenizer.nextToken());

context.write(word, one);

}

}

}

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 22 / 72

Page 32: Parallel Processing MapReduce, FlumeJava and Dryad

Example: Word Count - reduce

public static class MyReduce extends Reducer<...> {

public void reduce(Text key, Iterator<...> values, Context context)

throws IOException, InterruptedException {

int sum = 0;

while (values.hasNext())

sum += values.next().get();

context.write(key, new IntWritable(sum));

}

}

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 23 / 72

Page 33: Parallel Processing MapReduce, FlumeJava and Dryad

Example: Word Count - driver

public static void main(String[] args) throws Exception {

Configuration conf = new Configuration();

Job job = new Job(conf, "wordcount");

job.setOutputKeyClass(Text.class);

job.setOutputValueClass(IntWritable.class);

job.setMapperClass(MyMap.class);

job.setCombinerClass(MyReduce.class);

job.setReducerClass(MyReduce.class);

job.setInputFormatClass(TextInputFormat.class);

job.setOutputFormatClass(TextOutputFormat.class);

FileInputFormat.addInputPath(job, new Path(args[0]));

FileOutputFormat.setOutputPath(job, new Path(args[1]));

job.waitForCompletion(true);

}

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 24 / 72

Page 34: Parallel Processing MapReduce, FlumeJava and Dryad

Implementation

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 25 / 72

Page 35: Parallel Processing MapReduce, FlumeJava and Dryad

Architecture

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 26 / 72

Page 36: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Execution (1/7)

I The user program divides the input files into M splits.• A typical size of a split is the size of a HDFS block (64 MB).• Converts them to key/value pairs.

I It starts up many copies of the program on a cluster of machines.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 27 / 72

Page 37: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Execution (2/7)

I One of the copies of the program is master, and the rest are workers.

I The master assigns works to the workers.• It picks idle workers and assigns each one a map task or a reduce

task.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 28 / 72

Page 38: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Execution (3/7)

I A map worker reads the contents of the corresponding input splits.

I It parses key/value pairs out of the input data and passes each pairto the user defined map function.

I The intermediate key/value pairs produced by the map function arebuffered in memory.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 29 / 72

Page 39: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Execution (4/7)

I The buffered pairs are periodically written to local disk.• They are partitioned into R regions (hash(key) mod R).

I The locations of the buffered pairs on the local disk are passed backto the master.

I The master forwards these locations to the reduce workers.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 30 / 72

Page 40: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Execution (5/7)

I A reduce worker reads the buffered data from the local disks of themap workers.

I When a reduce worker has read all intermediate data, it sorts it bythe intermediate keys.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 31 / 72

Page 41: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Execution (6/7)

I The reduce worker iterates over the intermediate data.

I For each unique intermediate key, it passes the key and the cor-responding set of intermediate values to the user defined reducefunction.

I The output of the reduce function is appended to a final output filefor this reduce partition.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 32 / 72

Page 42: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Execution (7/7)

I When all map tasks and reduce tasks have been completed, themaster wakes up the user program.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 33 / 72

Page 43: Parallel Processing MapReduce, FlumeJava and Dryad

Hadoop MapReduce and HDFS

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 34 / 72

Page 44: Parallel Processing MapReduce, FlumeJava and Dryad

Fault Tolerance - Worker

I Detect failure via periodic heartbeats.

I Re-execute in-progress map and reduce tasks.

I Re-execute completed map tasks: their output is stored on the localdisk of the failed machine and is therefore inaccessible.

I Completed reduce tasks do not need to be re-executed since theiroutput is stored in a global filesystem.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 35 / 72

Page 45: Parallel Processing MapReduce, FlumeJava and Dryad

Fault Tolerance - Master

I State is periodically checkpointed: a new copy of master startsfrom the last checkpoint state.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 36 / 72

Page 46: Parallel Processing MapReduce, FlumeJava and Dryad

MapReduce Limitation

I Redundant processing

I Lack of early termination

I Lack of iteration

I Lack of interactive processing

I Lack of real-time processing

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 37 / 72

Page 47: Parallel Processing MapReduce, FlumeJava and Dryad

FlumeJava

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 38 / 72

Page 48: Parallel Processing MapReduce, FlumeJava and Dryad

Motivation (1/2)

I It is easy in MapReduce:words(doc.txt) | sort | uniq -c

I What about this one?words(doc.txt) | grep | sed | sort | awk | perl

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 39 / 72

Page 49: Parallel Processing MapReduce, FlumeJava and Dryad

Motivation (1/2)

I It is easy in MapReduce:words(doc.txt) | sort | uniq -c

I What about this one?words(doc.txt) | grep | sed | sort | awk | perl

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 39 / 72

Page 50: Parallel Processing MapReduce, FlumeJava and Dryad

Motivation (2/2)

I Big jobs in MapReduce run in more than one Map-Reduce stages.

I Reducers of each stage write to replicated storage, e.g., HDFS.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 40 / 72

Page 51: Parallel Processing MapReduce, FlumeJava and Dryad

FlumeJava

I FlumeJava is a library provided by Google to simply the creation ofpipelined MapReduce tasks.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 41 / 72

Page 52: Parallel Processing MapReduce, FlumeJava and Dryad

Parallel Collections

I A few classes that represent parallel collections and abstract awaythe details of how data is represented.

I PCollection<T>: an immutable bag of elements of type T.

I PTable<K, V>: an immutable multi-map with keys of type K andvalues of type V.

I The main way to manipulate these collections is to invoke a data-parallel operation (transform) on them.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 42 / 72

Page 53: Parallel Processing MapReduce, FlumeJava and Dryad

Parallel Collections

I A few classes that represent parallel collections and abstract awaythe details of how data is represented.

I PCollection<T>: an immutable bag of elements of type T.

I PTable<K, V>: an immutable multi-map with keys of type K andvalues of type V.

I The main way to manipulate these collections is to invoke a data-parallel operation (transform) on them.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 42 / 72

Page 54: Parallel Processing MapReduce, FlumeJava and Dryad

Parallel Collections

I A few classes that represent parallel collections and abstract awaythe details of how data is represented.

I PCollection<T>: an immutable bag of elements of type T.

I PTable<K, V>: an immutable multi-map with keys of type K andvalues of type V.

I The main way to manipulate these collections is to invoke a data-parallel operation (transform) on them.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 42 / 72

Page 55: Parallel Processing MapReduce, FlumeJava and Dryad

Transforms (1/2)

I parallelDo(): elementwise computation over an inputPCollection<T> to produce a new output PCollection<S>.

I groupByKey(): converts a multi-map of type PTable<K, V> intoa uni-map of type PTable<K, Collection<V>>.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 43 / 72

Page 56: Parallel Processing MapReduce, FlumeJava and Dryad

Transforms (1/2)

I parallelDo(): elementwise computation over an inputPCollection<T> to produce a new output PCollection<S>.

I groupByKey(): converts a multi-map of type PTable<K, V> intoa uni-map of type PTable<K, Collection<V>>.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 43 / 72

Page 57: Parallel Processing MapReduce, FlumeJava and Dryad

Transforms (2/2)

I combineValues(): takes an input PTable<K, Collection<V>>

and an associative combining function on Vs, and returns aPTable<K, V>, where each input collection of values has been com-bined into a single output value.

I flatten(): takes a list of PCollection<T>s and returns a sin-gle PCollection<T> that contains all the elements of the inputPCollections.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 44 / 72

Page 58: Parallel Processing MapReduce, FlumeJava and Dryad

Transforms (2/2)

I combineValues(): takes an input PTable<K, Collection<V>>

and an associative combining function on Vs, and returns aPTable<K, V>, where each input collection of values has been com-bined into a single output value.

I flatten(): takes a list of PCollection<T>s and returns a sin-gle PCollection<T> that contains all the elements of the inputPCollections.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 44 / 72

Page 59: Parallel Processing MapReduce, FlumeJava and Dryad

Word Count in FlumeJava

public class WordCount {

public static void main(String[] args) throws Exception {

Pipeline pipeline = new MRPipeline(WordCount.class);

PCollection<String> lines = pipeline.readTextFile(args[0]);

PCollection<String> words = lines.parallelDo(new DoFn<String, String>() {

public void process(String line, Emitter<String> emitter) {

for (String word : line.split("\\s+")) {

emitter.emit(word);

}

}

}, Writables.strings());

PTable<String, Long> counts = Aggregate.count(words);

pipeline.writeTextFile(counts, args[1]);

pipeline.done();

}

}

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 45 / 72

Page 60: Parallel Processing MapReduce, FlumeJava and Dryad

Dataflow Optimization (1/2)

I ParallelDo fusion

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 46 / 72

Page 61: Parallel Processing MapReduce, FlumeJava and Dryad

Dataflow Optimization (2/2)

I MapShuffleCombineReduce (MSCR): combining ParallelDo,GroupByKey, CombineValues, and Flatten into single MapRe-duces.

I Generalizes MapReduce• Multiple reducers/combiners• Multiple output per reducer• Pass-through outputs

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 47 / 72

Page 62: Parallel Processing MapReduce, FlumeJava and Dryad

FlumeJava Workflow

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 48 / 72

Page 63: Parallel Processing MapReduce, FlumeJava and Dryad

Dryad

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 49 / 72

Page 64: Parallel Processing MapReduce, FlumeJava and Dryad

Motivation (1/2)

I It is easy in MapReduce:words(doc.txt) | sort | uniq -c

I What about this one?words(doc.txt) | grep | sed | sort | awk | perl

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 50 / 72

Page 65: Parallel Processing MapReduce, FlumeJava and Dryad

Motivation (1/2)

I It is easy in MapReduce:words(doc.txt) | sort | uniq -c

I What about this one?words(doc.txt) | grep | sed | sort | awk | perl

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 50 / 72

Page 66: Parallel Processing MapReduce, FlumeJava and Dryad

Motivation (1/3)

I In Dryad, each job is represented with a DAG.

I Intermediate vertices write to channels.

I More operation than map and reduce, e.g., join and distribute.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 51 / 72

Page 67: Parallel Processing MapReduce, FlumeJava and Dryad

Motivation (3/3)

I Dataflow is a popular abstraction for parallel programming.

I Don’t worry about the global state of a system: just write sim-ple vertices that maintain local state and communicate with othervertices through edges.

I MapReduce is a simple form of dataflow, with two types vertices:the mapper and the reducer

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 52 / 72

Page 68: Parallel Processing MapReduce, FlumeJava and Dryad

Motivation (3/3)

I Dataflow is a popular abstraction for parallel programming.

I Don’t worry about the global state of a system: just write sim-ple vertices that maintain local state and communicate with othervertices through edges.

I MapReduce is a simple form of dataflow, with two types vertices:the mapper and the reducer

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 52 / 72

Page 69: Parallel Processing MapReduce, FlumeJava and Dryad

Motivation (3/3)

I Dataflow is a popular abstraction for parallel programming.

I Don’t worry about the global state of a system: just write sim-ple vertices that maintain local state and communicate with othervertices through edges.

I MapReduce is a simple form of dataflow, with two types vertices:the mapper and the reducer

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 52 / 72

Page 70: Parallel Processing MapReduce, FlumeJava and Dryad

Programming Model

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 53 / 72

Page 71: Parallel Processing MapReduce, FlumeJava and Dryad

Programming Model (1/2)

I Jobs are expressed as a Directed Acyclic Graph (DAG): dataflow

I Vertices are computations.

I Edges are communication channels.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 54 / 72

Page 72: Parallel Processing MapReduce, FlumeJava and Dryad

Programming Model (2/2)

I Each vertex can have several input and output channels.

I Each vertex runs one or more times.

I Stop when all vertices have completed their execution at least once.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 55 / 72

Page 73: Parallel Processing MapReduce, FlumeJava and Dryad

Graph Description Operators (1/2)

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 56 / 72

Page 74: Parallel Processing MapReduce, FlumeJava and Dryad

Graph Description Operators (2/2)

GraphBuilder XSet = moduleX^N;

GraphBuilder DSet = moduleD^N;

GraphBuilder MSet = moduleM^(N*4);

GraphBuilder SSet = moduleS^(N*4);

GraphBuilder YSet = moduleY^N;

GraphBuilder HSet = moduleH^1;

GraphBuilder XInputs = (ugriz1 >= XSet) ||

(neighbor >= XSet);

GraphBuilder YInputs = ugriz2 >= YSet;

GraphBuilder XToY = XSet >= DSet >> MSet >= SSet;

for (i = 0; i < N*4; ++i) {

XToY = XToY ||

(SSet.GetVertex(i) >= YSet.GetVertex(i/4));

}

GraphBuilder YToH = YSet >= HSet;

GraphBuilder HOutputs = HSet >= output;

GraphBuilder final = XInputs || YInputs ||

XToY || YToH || HOutputs;

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 57 / 72

Page 75: Parallel Processing MapReduce, FlumeJava and Dryad

Word Count in DryadLINQ

public class WordCount {

public static void WordCountExample() {

var config = new DryadLinqContext(1);

var lines = new LineRecord[] { new LineRecord("This is a dummy line") };

var input = config.FromEnumerable(lines);

var words = input.SelectMany(x => x.Line.Split(’ ’));

var groups = words.GroupBy(x => x);

var counts = groups.Select(x =>

new KeyValuePair<string, int>(x.Key, x.Count()));

var toOutput = counts.Select(x =>

new LineRecord(String.Format("{0}: {1}", x.Key, x.Value)));

foreach (LineRecord line in toOutput) {

Console.WriteLine(line.Line);

}

}

}

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 58 / 72

Page 76: Parallel Processing MapReduce, FlumeJava and Dryad

Implementation

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 59 / 72

Page 77: Parallel Processing MapReduce, FlumeJava and Dryad

Dryad Architecture

I Job manager (JM)

I Vertices (V)

I Daemon (D)

I Name server (NS)

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 60 / 72

Page 78: Parallel Processing MapReduce, FlumeJava and Dryad

Job Manager

I Constructs the job’s DAG.

I Schedule the work across the available resources in the cluster

I Dynamic graph refinements.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 61 / 72

Page 79: Parallel Processing MapReduce, FlumeJava and Dryad

Vertices and Channels

I Vertex: arbitrary binary application code.• The binary code will be sent to the corresponding node directly

from the JM.

I Channels: transport a finite sequence of structured items betweenvertices.

• Files, TCP pipes, or shared memory (FIFO)

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 62 / 72

Page 80: Parallel Processing MapReduce, FlumeJava and Dryad

Daemons

I Running on each computer in the cluster.

I Create processes on behalf of the JM.

I As a proxy that so that the JM can communicate with the remotevertices.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 63 / 72

Page 81: Parallel Processing MapReduce, FlumeJava and Dryad

Name Server

I Enumerate all the available computers in the cluster.

I Exposes the position of each computer within the network topology:locality.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 64 / 72

Page 82: Parallel Processing MapReduce, FlumeJava and Dryad

Dryad Execution (1/2)

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 65 / 72

Page 83: Parallel Processing MapReduce, FlumeJava and Dryad

Dryad Execution (2/2)

I Dataflow is mapped on a set of computation engines.

I During the runtime the JM monitors the states of the verticesthrough the daemons.

I When all input channels of a vertex become ready a new executionrecord is created for the vertex and placed in a scheduling queue.

I Prefer executing a vertex near its inputs.

I If every vertex eventually completes then the job is deemed to havecompleted successfully.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 66 / 72

Page 84: Parallel Processing MapReduce, FlumeJava and Dryad

Job Stages and Scalability (1/2)

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 67 / 72

Page 85: Parallel Processing MapReduce, FlumeJava and Dryad

Job Stages and Scalability (2/2)

I Stage manager• Locality• Replicated stages to avoid straggler problem

I words(doc.txt) | grep | sed | sort | awk | perl

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 68 / 72

Page 86: Parallel Processing MapReduce, FlumeJava and Dryad

Fault Tolerance

I JM fails• Computation fails.

I Vertex computation fails• Restart vertex with different version number.• Previous instance of vertex may run in parallel with new instances.

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 69 / 72

Page 87: Parallel Processing MapReduce, FlumeJava and Dryad

Summary

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 70 / 72

Page 88: Parallel Processing MapReduce, FlumeJava and Dryad

Summary

I Scaling out: shared nothing architecture

I MapReduce• Programming model: Map and Reduce• Execution framework

I FlumeJava• Dataflow DAG• Parallel collection: PCollection and PTable• Transforms: ParallelDo, GroupByKey, CombineValues, Flatten

I Dryad• Dataflow DAG• Job manage, vertices and channels, name server

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 71 / 72

Page 89: Parallel Processing MapReduce, FlumeJava and Dryad

Questions?

Amir H. Payberah (KTH) Parallel Processing 2016/09/12 72 / 72


Recommended