map reduce : simplified data processing on large clusters presented by: simarpreet gill

25
MAP REDUCE : MAP REDUCE : SIMPLIFIED DATA SIMPLIFIED DATA PROCESSING PROCESSING ON LARGE CLUSTERS ON LARGE CLUSTERS Presented by: Simarpreet Presented by: Simarpreet Gill Gill

Upload: myles-quinn

Post on 12-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

MAP REDUCE : SIMPLIFIED MAP REDUCE : SIMPLIFIED DATA PROCESSINGDATA PROCESSING

ON LARGE CLUSTERSON LARGE CLUSTERS

Presented by: Simarpreet GillPresented by: Simarpreet Gill

Page 2: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

IntroductionIntroduction

► MapReduce is a programming model and an associated MapReduce is a programming model and an associated implementation for processing and generating large implementation for processing and generating large datasets.datasets.

► Users specify the following two functions:Users specify the following two functions:

* Map – processes a key/value pairs* Map – processes a key/value pairs

*Reduce – merges all intermediate values associated *Reduce – merges all intermediate values associated with the same intermediate keywith the same intermediate key

Page 3: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

► Many real world tasks are expressible in this modelMany real world tasks are expressible in this model► Programs written in this functional style are Programs written in this functional style are

automatically parallelized and executed on a large automatically parallelized and executed on a large cluster of commodity machinescluster of commodity machines

► The run-time system takes care of the details of The run-time system takes care of the details of partitioning the input data, scheduling the program’s partitioning the input data, scheduling the program’s execution across a set of machines, handling machine execution across a set of machines, handling machine failures, and manage the required inter-machine failures, and manage the required inter-machine communication.communication.

Page 4: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

Programming ModelProgramming Model

► The user of the MapReduce library expresses the The user of the MapReduce library expresses the computation as two functions : Map and Reducecomputation as two functions : Map and Reduce

► Map, written by the user, takes an input pair and Map, written by the user, takes an input pair and produces a set of intermediate key/value pairsproduces a set of intermediate key/value pairs

► The Reduce function, also written by the user , accepts The Reduce function, also written by the user , accepts an intermediate key I and a set of values for that key. It an intermediate key I and a set of values for that key. It merges together these values to form a possibly smaller merges together these values to form a possibly smaller set of valuesset of values

Page 5: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

ExampleExample

map(String key, String value):map(String key, String value): // key: document name// key: document name // value: document contents// value: document contents for each word w in value:for each word w in value: EmitIntermediate(w, "1");EmitIntermediate(w, "1");reduce(String key, Iterator values):reduce(String key, Iterator values): // key: a word// key: a word // values: a list of counts// values: a list of counts int result = 0;int result = 0; for each v in values:for each v in values: result += ParseInt(v);result += ParseInt(v); Emit(AsString(result));Emit(AsString(result));

Page 6: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

TypesTypes

►The map and reduce functions The map and reduce functions supplied by the user have associated supplied by the user have associated types:types:

* map (k1,v1) -> list(k2,v2)* map (k1,v1) -> list(k2,v2)

* reduce (k2,list(v2)) -> list(v2)* reduce (k2,list(v2)) -> list(v2)

i.e., the input keys and values are drawn i.e., the input keys and values are drawn from a different domain than the from a different domain than the output keys and values.output keys and values.

Page 7: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

More ExamplesMore Examples

►Distributed GrepDistributed Grep►Count of URL Access FrequencyCount of URL Access Frequency►Reverse Web-Link GraphReverse Web-Link Graph►Term-Vector per HostTerm-Vector per Host►Inverted IndexInverted Index►Distributed SortDistributed Sort

Page 8: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

ImplementationImplementation

► Many different implementations of the MapReduce Many different implementations of the MapReduce interface are possible. The right choice depends on the interface are possible. The right choice depends on the environment.environment.

► Following slides describe an implementation targeted to Following slides describe an implementation targeted to the computing environment in wide use at Google: the computing environment in wide use at Google: large clusters of commodity PCs connected together large clusters of commodity PCs connected together with switched Ethernet.with switched Ethernet.

Page 9: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

► Machines are typically dual-processor x86 processors running Linux, with 2-4 GB of memory per machine.

►Commodity networking hardware is used . Typically either 100 megabits/second or 1 gigabit/second at the machine level, but averaging considerably less in over-all bisection bandwidth.

►A cluster consists of hundreds or thousands of machines, and therefore machine failures are common.

Page 10: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

► Storage is provided by inexpensive IDE disks attached directly to individual machines. A distributed file system developed in-house is used to manage the data stored on these disks. The file system uses replication to provide availability and reliability on top of unreliable

hardware.

►Users submit jobs to a scheduling system. Each job consists of a set of tasks, and is mapped by the scheduler to a set of available machines within a cluster.

Page 11: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

Execution OverviewExecution Overview

► The map invocations are distributed across multiple The map invocations are distributed across multiple machines by automatically partitioning the input data machines by automatically partitioning the input data into a set of M splits.into a set of M splits.

► The input splits can be processed in parallel by different The input splits can be processed in parallel by different machines.machines.

► Reduce invocations are distributed by partitioning the Reduce invocations are distributed by partitioning the intermediate key space into R pieces using a partioning intermediate key space into R pieces using a partioning function.function.

Page 12: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

►The MapReduce library in the user program first splits the input les into M pieces of typically 16 megabytes to 64 megabytes (MB) per piece (controllable by the user via an optional parameter). It then starts up many copies of the program on a cluster of machines.

►One of the copies of the program is special – the master. The rest are workers that are assigned work by the master. There are M map tasks and R reduce tasks to assign. The master picks idle workers and assigns each one a map task or a reduce task.

Page 13: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

►A worker who is assigned a map task reads the contents of the corresponding input split. It parses

key/value pairs out of the input data and passes each pair to the user-defined Map function. The intermediate key/value pairs produced by the Map function are buffered in memory.

► Periodically, the buffered pairs are written to local disk, partitioned into R regions by the partitioning function

Page 14: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

►When a reduce worker is notified by the master about these locations, it uses remote procedure calls to read the buffered data from the local disks of the map workers.

►The reduce worker iterates over the sorted intermediate data and for each unique intermediate key encountered ,it passes the key and the corresponding set of intermediate values to the user's Reduce function. The output of the Reduce function is appended to a final output le for this reduce partition.

Page 15: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

►After successful completion, the output of the mapreduce execution is available in the R output les (one per reduce task, with le names as specfied by the user).

Page 16: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

Master Data StructuresMaster Data Structures

►The master keeps several data structures. For each map task and reduce task, it stores the state (idle, in-progress, or completed), and the identity of the worker machine (for non-idle tasks).

Page 17: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

Fault ToleranceFault Tolerance

► Worker failureWorker failure

The master pings every worker periodically. If no response is received from a worker in a certain amount of time, the master marks the worker as failed.

►Master failure

It is easy to make the master write periodic checkpoints of the master data structures. If the master task dies, a new copy can be started from the last check pointed state.

Page 18: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

Semantics in the presence of Semantics in the presence of FailuresFailures

►When the user-supplied map and reduce operators are deterministic functions of their input values, our distributed implementation produces the same output as would have been produced by a non-faulting sequential execution of the entire program.

►We rely on atomic commits of map and reduce task outputs to achieve this property.

Page 19: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

LocalityLocality

►Network bandwidth is a relatively scarce resource in our computing environment. We conserve network bandwidth by taking advantage of the fact that the input data is stored on the local disks of the machines that make up our cluster.

Page 20: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

Task GranularityTask Granularity

►We subdivide the map phase into M pieces and the reduce phase into R pieces, as described above. Ideally , M and R should be much larger than the number of worker machines.

►Having each worker perform many different tasks improves dynamic load balancing, and also speeds up recovery when a worker fails: the many map tasks it has completed can be spread out across all the other worker machines.

Page 21: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

Backup TasksBackup Tasks

►One of the common causes that lengthens the total time taken for a MapReduce operation is a .straggler.: a machine that takes an unusually long time to complete one of the last few map or reduce tasks in the computation.

►We have a general mechanism to alleviate the problem of stragglers. When a MapReduce operation is close to completion, the master schedules backup executions of the remaining in-progress tasks.

Page 22: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

RefinementsRefinements

► Although the basic functionality provided by simply Although the basic functionality provided by simply writing Map and Reduce functions is sufficient for most writing Map and Reduce functions is sufficient for most needs, few extensions have been found useful:needs, few extensions have been found useful:

• Partitioning FunctionPartitioning Function• Ordering GuaranteesOrdering Guarantees• Combiner FunctionCombiner Function• Input and Output TypesInput and Output Types• Side-effectsSide-effects• Skipping Bad RecordsSkipping Bad Records

Page 23: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

• Local ExecutionLocal Execution• Status InformationStatus Information• CountersCounters

Page 24: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill

ConclusionsConclusions

► The MapReduce programming model has been The MapReduce programming model has been successully used at Google for many different purposes.successully used at Google for many different purposes.

This success has been attributed to several reasons.This success has been attributed to several reasons.• The model is easy to use even for programmers without The model is easy to use even for programmers without

experience with parallel and distributed systems.experience with parallel and distributed systems.• A large variety of problems are easily expressible as A large variety of problems are easily expressible as

MapReduce computations.MapReduce computations.• An implementation of MapReduce has been developed An implementation of MapReduce has been developed

that scales to large clusters of machines comprising that scales to large clusters of machines comprising thousands of machines.thousands of machines.

Page 25: MAP REDUCE : SIMPLIFIED DATA PROCESSING ON LARGE CLUSTERS Presented by: Simarpreet Gill