Question

How does a node processing running the mapper knows that it has to send some key-value output to node A (running the reducer) & some to node B (running another reducer)? Is there somewhere a reducer node list is maintained by the the JobTracker? If yes, how does it chooses a node to run the reducer?

Was it helpful?

Solution

A Mapper doesn't really know where to send the data, it focuses on 2 things:

  • Writes the data to disk. Initially the map output is buffered in memory, and once it hits a certain threshold it gets flushed to disk. But right before going to disk, the data is partitioned by taking a hash of the output key which corresponds to which Reducer it will be sent to.
  • Once a map task is done it will notify the parent task tracker to say it's done, which will then notify the job tracker itself. So the job tracker has the complete mapping between map outputs and task trackers.

From there, when a Reducer starts, it will keep asking the job tracker for the map outputs corresponding to his partition until it has retrieved them all. Whenever a map output is available, the reduce task will start copying it, and gradually merge as it copies.

If this is still unclear, I will advise looking at the reference book on Hadoop which has a whole chapter describing this part, here is a schema extracted from it that could help you visualize what happens in the shuffle step:

enter image description here

OTHER TIPS

The mappers do not send the data to the reducers, rather the reducers pull the data from the task trackers where successful map tasks ran.

The Job Tracker, when allocating a reducer task to a task tracker, knows where the successful map tasks ran, and can compile a list of task tracker and map attempt task results to pull.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top