MUNI FI MapReduce: Simplified Data Processing on Large Clusters PA154 Language Modeling (8.3) Pavel Rychlý pary@fi.muni.cz April 16, 2024 Source: Jeff Dean, Sanjay Ghemawat Google, Inc. December, 2004 https ://research.google/pubs/pub62/ Davel Rychlý ■ MapReduce ■ April 16, 2024 Motivation: Large Scale Data Processing Many tasks: Process lots of data to produce other data Want to use hundreds or thousands of CPUs ■ ... but this needs to be easy MapReduce provides: ■ Automatic parallelization and distribution ■ Fault-tolerance ■ I/O scheduling ■ Status and monitoring Davel Rychlý ■ MapReduce ■ April 16, 2024 Programming model Input & Output: each a set of key/value pairs Programmer specifies two functions: map (in.key, in.value) -> I i s t (out.key , intermediate.value ) ■ Processes input key/value pair ■ Produces set of intermediate pairs reduce (out-key, I ist (intermediate-value )) -> list ( out.value ) ■ Combines all intermediate values for a particular key ■ Produces a set of merged output values (usually just one) Inspired by similar primitives in LISP and other languages Davel Rychlý ■ MapReduce ■ April 16, 2024 3 /32 Example: Count word occurrences map(String input-key, String input-value ): // input.value: document contents for each word w in input-value: Emitlntermediate (w, "1"); 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 += Parselnt(v); Emit(AsString (result)); Pseudocode: See appendix in paper for real code Davel Rychlý ■ MapReduce ■ April 16, 2024 4/ 32 Model is Widely Applicable MapReduce Programs In Google Source Tree Implementation Overview Example uses: distributed grep term-vector per host document clustering distributed sort web access log stats machine learning web link-graph reversal inverted index construction statistical machine translation Typical cluster: ■ 100s/1000s of 2-CPU x86 machines, 2-4 GB of memory ■ Limited bisection bandwidth ■ Storage is on local IDE disks ■ GFS: distributed file system manages data (SOSP'03) ■ Job scheduling system: jobs made up of tasks, scheduler assigns tasks to machines Implementation is a C++ library linked into user programs Davel Rychlý ■ MapReduce ■ April 16, 2024 5/32 Davel Rychlý ■ MapReduce ■ April 16, 2024 6/32 Execution Parallel Execution Task Granularity And Pipelining Fine granularity tasks: many more map tasks than machines Minimizes time for fault recovery ■ Can pipeline shuffling with map execution ■ Better dynamic load balancing Often use 200,000 map/5000 reduce tasks/ 2000 machines Worker 1 Worker 1 Worker 3 Worker 4 MapRediiceQ Assign tasks to worker machines... Map 1 Map 3 Map 2 Read [Read 1.31 Read 2.1 Read 1.2 [Reduce 11_ (Read 2.2 I Read 2.3 I Reduce 2 Davel Rychly ■ MapReduce ■ April 16, 2024 MapReduce status: MR_Indexer-beta64arge-2003_10_28_00_03 Started: FriNov? 09:51:07 2003 --up 0 hr 00 rniri 18 sec 323 workers; 0 deaths Type Shards Do »» Activs Input(MB) Do neCMB) OutputfMB) Map 13S53 (i 323 878934 6 1314.4 717.0 Shuffle 500 0 323 717 C 0.0 0.0 T:rdi:rr 500 0 ij 0 0 0.0 0.0 I- a •» £ 30 Reduce Shard Variable Minute Mapped (MB/s) 72.5 Shuffle (MB/s) 0 0 Output (MB/s) 0.0 index-hits 145825686 docs-indexed 506631 dups-in-index-merge 0 op fir a tor-calls 508192 506631 Davel Rychly ■ MapReduce ■ April 16, 2024 MapReduce status: MR_Indexer-beta64axge-2003_10_28_00_03 Started: Fri Nov 7 09 51:07 2003 --up C lir05niin 07 sec 1707 workers; 1 deaths Type Shards Done Active InputflVEB) Done Dcne(ME) Output(ME) Map 13353 13Ě53 0 878934.6 378934.5 523439.2 Shuffle 500 500 0 523499 2 523499.5 5234 99. 5 Reduce 500 0 500 523499 5 133837.8 136929.6 Counters Y an able I.Ilipj. ed (MB/s) Shuffle (MB/s) Reduce Slioid Started' FhKot7 09:51:07 2003 -- up 0 hr33n 1707 workers; 1 deaths Type Shaids Done Active Input(MB) Done(MB) Output(MB) Map 13853 13853 0 378934 6 373934 6 523499.2 31 „ ,jflr 500 500 0 523499 2 523499 5 523499 5 Reduce 500 Vaiiable Minute Mapped (MB/s) Shuffle (MB/s) Output (MB/s) in de:-:-hits docs- indexed Davel Rychlý ■ MapReduce ■ April 16, 2024 Davel Rychlý ■ MapReduce ■ April 16, 2024 MapReduce status: MR_Indexer-betaó-large-2003_10_28_00_03 Started Fri Nov 7 09:51:07 2003 - up 0 hr 35 mm OS sec 1707 workers; 1 deaths Type Shards Done Active Input(ME) Done(ME) Output(ME) Map 13353 13853 0 878934 6 878934.6 523499.2 Shuffle 500 500 0 523499.2 523499.5 523499.5 deduce 500 0 500 523499.5 390447.6 399457.2 (MB/s) MapReduce status: MR_Indexer-beta6-large-2003_10_28_00_03 Started: Fri Kov 7 09:51:07 2003 - up 0 hr 37 mm 01 sec 707 workers: 1 deaths Type Shards Done Active Input(MB) Done (MB Output(MB) Map 13853 13853 0 37393495 373934 I 523499.2 Shuffle 500 500 0 523499.21 520468.É 520468.6 Ii.č.:;ui:.č 500 406 94 520468 6| 512265.2 514373.3 1W ■■ Reduce Sherd Variable Mapped (MB/s; SlmtEe (MB/s; Output (MB/s) md>::-:cd index-merge merge- 35D83350 outouts Davel Rychlý ■ MapReduce ■ April 16, 2024 17/32 Davel Rychlý ■ MapReduce ■ April 16, 2024 18/32 ^5455^5482828793932379 MapReduce status: MR_Lidexer-beta6-large-2003_10_2S_00_03 MapReduce status: MR_lndexer-beta6-large-2003_10 28 00 03 Started Fn Nov 7 09.51:07 2003 -- u? 0 hr 38 mm 56 sec 1707 workers; 1 cieaths Type Shards Dune Active DiputiMB) Doii_(ME) 0_rp_t(MB) Map 13853 -.3353 C S78934.. 873934.. 523499.2 Shuffle 500 50. C 519781.8 519781.8 B.e_ui.:e 5 CO 49_ 1 519731.8 519354.7 519440 7 _____ Started. Fa Nov 7 09.51.07 2003 - up 0 hr 40 rr 1707 workers; 1 deaths Rpriurp 'ilmr.l Variable Minute Mappe ■.: (MB/s) 0.0 Shuffle 0_B/s) 0.0 Output C__/e) 9.4 doc-index-h-ts 0 1051 docs-tndexed 0 merge 0 merge -calls 394792 outouts 394792 Type Shards Done Active Inp_t(__B) Done(MB) Output(MB) Map 13853 13353 C 878934 6 378934 6 523499.2 Skitfle 500 500 c 523499.2 519774 3 519774 3 Reduce 500 495 1 519774.3 5197352 519764.0 Reduce Shard Variable Minute Mapped (MB/s) 0.0 Shuffle CMB/s) 0.0 1 Output 1 bfWa) 1.9 1 index-hits 0 105 0 II dups-in-I indME-II merge 0 1 merge- 73442 K merge -1 ourouts 73442 Davel Rychlý ■ MapReduce ■ April 16, 2024 Davel Rychlý ■ MapReduce ■ April 16, 2024 Fault tolerance: Handled via re-execution Refinement: Redundant Execution ■ On worker failure: ■ Detect failure via periodic heartbeats ■ Re-execute completed and in-progress map tasks ■ Re-execute in progress reduce tasks ■ Task completion committed through master ■ Master failure: ■ Could handle, but don't yet (master failure unlikely) Robust: lost 1600 of 1800 machines once, but finished fine Semantics in presence of failures: see paper Slow workers significantly lengthen completion time ■ Other jobs consuming resources on machine ■ Bad disks with soft errors transfer data very slowly ■ Weird things: processor caches disabled (!!) Solution: Near end of phase, spawn backup copies of tasks ■ Whichever one finishes first "wins" Effect: Dramatically shortens job completion time Davel Rychlý ■ MapReduce ■ April 16, 2024 Davel Rychlý ■ MapReduce ■ April 16, 2024 Refinement: Locality Optimization Refinement: Skipping Bad Records Master scheduling policy: ■ Asks GFS for locations of replicas of input file blocks ■ Map tasks typically split into 64MB (== GFS block size) ■ Map tasks scheduled so GFS input block replica are on same machine or same rack Effect: Thousands of machines read input at local disk speed ■ Without this, rack switches limit read rate Map/Reduce functions sometimes fail for particular inputs ■ Best solution is to debug & fix, but not always possible ■ On seg fault: ■ Send UDP packet to master from signal handler ■ Include sequence number of record being processed ■ If master sees two failures for same record: ■ Next worker is told to skip the record Effect: Can work around bugs in third-party libraries Davel Rychlý ■ MapReduce ■ April 16, 2024 23/32 Davel Rychlý ■ MapReduce ■ April 16, 2024 24/32 Other Refinements (see paper) Sorting guarantees within each reduce partition Compression of intermediate data Combiner: useful for saving network bandwidth Local execution for debugging/testing User-defined counters Performance Tests run on cluster of 1800 machines: ■ 4 GB of memory ■ Dual-processor 2 GHz Xeons with Hyperthreading ■ Dual 160 GB IDE disks ■ Gigabit Ethernet per machine ■ Bisection bandwidth approximately 100 Gbps Two benchmarks: MR.Grep Scan 1010 100-byte records to extract records matching a rare pattern (92K matching records) MFLSort Sort1010 100-byte records (modeled after TeraSort benchmark) Davel Rychly ■ MapReduce ■ April 16, 2024 Davel Rychly ■ MapReduce ■ April 16, 2024 MR_Grep Locality optimization helps: ■ 1800 machines read 1 TB of data at peak of ~ 31 GB/s ■ Without this, rack switches would limit to 10 GB/s Startup overhead is significant for short jobs MR_Sort ■ Backup tasks reduce job completion time significantly ■ System deals well with failures Normal 20000 n Done: No backup tasks 200 processes killed zoo':': -| Davel Rychly ■ MapReduce ■ April 16, 2024 Davel Rychly ■ MapReduce ■ April 16, 2024 Experience: Rewrite of Production Indexing System Rewrote Google's production indexing system using MapReduce ■ Set of +0, 44, 47, 24, 24 MapReduce operations ■ New code is simpler, easier to understand ■ MapReduce takes care of failures, slow machines ■ Easy to make indexing faster by adding more machines Usage: MapReduce jobs run in August 2004 Number of jobs 29,423 Average job completion time 634 sees Machine days used 79,186 days Input data read 3,288 TB Intermediate data produced 758 TB Output data written 193 TB Average worker machines per job 157 Average worker deaths per job 1.2 Average map tasks per job 3,351 Average reduce tasks per job 55 Unique map implementations 395 Unique reduce implementations 269 Unique map/reduce combinations 426 Davel Rychly ■ MapReduce ■ April 16, 2024 29/32 Davel Rychly ■ MapReduce ■ April 16, 2024 30/32 Related Work Conclusions Programming model inspired by functional language primitives Partitioning/shuffling similar to many large-scale sorting systems ■ NOW-Sort ['97] Re-execution for fault tolerance ■ BAD-FS ['04] and TACC ['97] Locality optimization has parallels with Active Disks/Diamond work ■ Active Disks ['01], Diamond ['04] Backup tasks similar to Eager Scheduling in Charlotte system ■ Charlotte ['96] Dynamic load balancing solves similar problem as River's distributed queues ■ River ['99] MapReduce has proven to be a useful abstraction Greatly simplifies large-scale computations at Google Fun to use: focus on problem, let library deal w/ messy details Thanks to Josh Levenberg, who has made many significant improvements and to everyone else at Google who has used and helped to improve MapReduce. Davel Rychlý ■ MapReduce ■ April 16, 2024 31 /32 Davel Rychlý ■ MapReduce ■ April 16, 2024 32/32