1 / 32

MapReduce Implementation for Distributed Computing

This lecture discusses the implementation of MapReduce, including input handling, map function, partition function, compare function, reduce function, and output writer. It also covers the advantages, hardware considerations, task assignment, and failure handling in MapReduce. Various topics such as stragglers, crashes, non-determinism, and advanced techniques like combiner function and counters are also discussed.

waldoa
Download Presentation

MapReduce Implementation for Distributed Computing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 3 – MapReduce: Implementation CSE 490h – Introduction to Distributed Computing, Spring 2009 Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 License.

  2. Last Class • Input Handling • Map Function • Partition Function • Compare Function • Reduce Function • Output Writer

  3. map (Functional Programming) Creates a new list by applying f to each element of the input list; returns output in order. map f lst: (’a->’b) -> (’a list) -> (’b list)

  4. Fold Moves across a list, applying f to each element plus an accumulator. f returns the next accumulator value, which is combined with the next element of the list fold f x0 lst: ('a*'b->'b)->'b->('a list)->'b

  5. Advantages of MapReduce • Flexible for a wide range of problems • Fault tolerant • Scalable

  6. Overview • Hardware • Task assignment • Failure • Non-Determinism • Optimizations

  7. Commodity Hardware • Cheap Hardware • 2 – 4 GB memory • 100 megabit / sec • x86 processors running Linux • Cheap Hardware + Lots of It = Failure!

  8. Master vs Worker • Users submit jobs into scheduling system • Implement map and reduce • Specify M map tasks and R reducers • Many copies of program started • One task is the master • Master assigns map/reduce tasks to idle workers

  9. Map Tasks • Input broken up into 16MB - 64MB chunks • M map tasks processed in parallel

  10. Reduce Tasks • R reduce tasks • Assigned by partitioning function • Typically: hash(key) mod R • Sometimes useful to customize

  11. Master Data Structures • For each map / reduce task, store state and identity of machine • State: Idle, In-Progress, Complete • For each complete map task, store locations of output (R locations)

  12. Worker with Map Tasks • Parses input data into key/value pairs • Applies map • Buffered pairs written to disk, partitioned into R regions • Locations of output eventually passed to master

  13. Worker with Reduce Tasks • Read data from map machines via RPC • Sorts data • Applies reduce • Output appended to final output file

  14. After Reduce • When all complete, master wakes up user program • Output available in R output files, with names specified by user

  15. How do you pick M and R • How many scheduling decisions? • O(M+R) • How much state in memory by master? • O(M*R) • M: much larger than number of machines • R: small multiple of number of machines

  16. Failures & Issues • Worker Failure • Master Failure • Stragglers • Crashes, Etc

  17. Worker Failure • Master pings worker • No response -> assumes failed • Failed map tasks • Completed & In-Progress tasks set to idle • Failed reduce tasks • In-Progress tasks set to idle

  18. Master Failure • You could write checkpoints • In practice: just let the user deal with it

  19. Stragglers (Causes) • Why? • Bad disk but correctable errors • Too many other tasks • No caching

  20. Stragglers (Solutions) • Re-schedule remaining tasks when operation is close to completion • A task is complete when either primary or secondary task is complete

  21. Crashes, Etc • Causes: • Bad Records • Bug in Third Party Code • Solution: Skip over errors?

  22. Non-Determinism • Deterministic = distributed implementation produces same result as sequential execution • Non-Deterministic = map or reduce are non-deterministic

  23. Non-Determinism • Guarantee: output for a specific reduce task is equivalent to some sequential operation • But: output from different reduce tasks may correspond to different sequential operations

  24. Non-Determinism • There may be no sequential operation that matches the full output • Why? • Because R1 and R2 may have read outputs for the differentexecution of M

  25. Advanced Stuff • Input Types • Combiner Function • Counters

  26. Input Types • May need to change how input is read • Implement reader interface

  27. Combiner • “Combiner” functions can run on same machine as a mapper • Causes a mini-reduce phase to occur before the real reduce phase, to save bandwidth Under what conditions is it sound to use a combiner?

  28. Combiner Function • Can only be used if communicative and associative • Communicative: a + b + c = b + c + a • Associative: (a × b) × c = a × (b × c)

  29. Counters • Global Counter • Masters handles issue of duplicate executions • Useful for sanity checking or debugging

  30. Discussion Questions • 1. Give an example of a MapReduce problem not listed in the reading. In your example, what are the map and reduce functions (including inputs and outputs)? • 2. What part of the MapReduce implementation do you find most interesting? Why? • 3. Give an example of a distributable problem that should not be solved with MapReduce. What are the limitations of MapReduce that make it ill-suited for your task?

  31. Discussion Questions • 1.   Assuming you had a corpus of webpages as input such that the key     for each mapper is the URL and the value is the text of the page,      how would you design a mapper and a reducer to construct an     inverse graph of the web - that is, for each URL output the list     of web pages that point to it?  2. TF–IDF is a statistical value assigned to words in a document      corpus that indicates the relative importance of the word. As part     of computing it, the Inverse Document Frequency of a word is found     from: The number of documents in the corpus divided by the number      of documents containing the word. Given a corpus of documents, and     given that you know how many documents are in the corpus, how     would you use map reduce to find this quantity for every word in      the corpus simultaneously?

More Related