Google云計算技術(shù)MapReduce國外課件.ppt
MapReduce: Simplified Data Processing on Large Clusters,Jeffrey Dean reduce(String output_key, Iterator intermediate_values): / output_key: a word / output_values: a list of counts int result = 0; for each v in intermediate_values: result += ParseInt(v); Emit(AsString(result);,More Examples,Distributed grep: Map: (key, whole doc/a line) (the matched line, key) Reduce: identity function,More Examples,Count of URL Access Frequency: Map: logs of web page requests (URL, 1) Reduce: (URL, total count),More Examples,Reverse Web-Link Graph: Map: (source, target) (target, source) Reduce: (target, list(source) (target, list(source),MapReduce: Execution overview,Architecture,Master Data Structure Task state: idle, in-progress, completed Identity of worker machine: for in-progress tasks Location of intermediate file regions of map tasks. Receive from map tasks Push to reduce tasks.,Execution overview,Split input files (1) Master and workers (2) Map task workers (3) Buffering of results (4) Copying and sorting (5) Reduce workers (6) Return to user code (7),MapReduce: Execution overview,MapReduce: Example,MapReduce in Parallel: Example,MapReduce: Runtime Environment,Fault Management,Fault Tolerance in a word: redo Master pings workers, re-schedules failed tasks. Note: Completed map tasks are re-executed on failure because their output is stored on the local disk. Master failure: redo Semantics in the presence of failures: Deterministic map/reduce function: Produce the same output as would have been produced by a non-faulting sequential execution of the entire program Rely on atomic commits of map and reduce task outputs to achieve this property.,MapReduce: Fault Tolerance,Handled via re-execution of tasks. Task completion committed through master What happens if Mapper fails ? Re-execute completed + in-progress map tasks What happens if Reducer fails ? Re-execute in progress reduce tasks What happens if Master fails ? Potential trouble !,MapReduce: Refinements Locality Optimization,Leverage GFS to schedule a map task on a machine that contains a replica of the corresponding input data. Thousands of machines read input at local disk speed Without this, rack switches limit read rate,MapReduce: Refinements Redundant Execution,Slow workers are source of bottleneck, may delay completion time. Near end of phase, spawn backup tasks, one to finish first wins. Effectively utilizes computing power, reducing job completion time by a factor.,MapReduce: Refinements Skipping Bad Records,Map/Reduce functions sometimes fail for particular inputs. Fixing the Bug might not be possible : Third Party Libraries. On Error Worker sends signal to Master If multiple error on same record, skip record,MapReduce: Refinements Miscellaneous,Combiner Function at Mapper Sorting Guarantees within each reduce partition. Local execution for debugging/testing User-defined counters,MapReduce:,Walk through of One more Application,MapReduce : PageRank,PageRank models the behavior of a “random surfer”. C(t) is the out-degree of t, and (1-d) is a damping factor (random jump) The “random surfer” keeps clicking on successive links at random not taking content into consideration. Distributes its pages rank equally among all pages it links to. The dampening factor takes the surfer “getting bored” and typing arbitrary URL.,Computing PageRank,PageRank : Key Insights,Effect at each iteration is local. i+1th iteration depends only on ith iteration At iteration i, PageRank for individual nodes can be computed independently,PageRank using MapReduce,Use Sparse matrix representation (M) Map each row of M to a list of PageRank “credit” to assign to out link neighbours. These prestige scores are reduced to a single PageRank value for a page by aggregating over them.,PageRank using MapReduce,Source of Image: Lin 2008,Phase 1: Process HTML,Map task takes (URL, page-content) pairs and maps them to (URL, (PRinit, list-of-urls) PRinit is the “seed” PageRank for URL list-of-urls contains all pages pointed to by URL Reduce task is just the identity function,Phase 2: PageRank Distribution,Reduce task gets (URL, url_list) and many (URL, val) values Sum vals and fix up with d to get new PR Emit (URL, (new_rank, url_list) Check for convergence using non parallel component,MapReduce: Some More Apps,Distributed Grep. Count of URL Access Frequency. Clustering (K-means) Graph Algorithms. Indexing Systems,MapReduce Programs In Google Source Tree,MapReduce Jobs run in Aug, 2004,MapReduce: Extensions and similar apps,PIG (Yahoo) Hadoop (Apache) DryadLinq (Microsoft),Large Scale Systems Architecture using MapReduce,Take Home Messages,Although restrictive, provides good fit for many problems encountered in the practice of processing large data sets. Functional Programming Paradigm can be applied to large scale computation. Easy to use, hides messy details of parallelization, fault-tolerance, data distribution and load balancing from the programmers. And finally, if it works for Google, it should be handy !,