- 2074 Bhadra · 8 marks
MapReduce data flow technique
Short answer
Data flows from HDFS input splits to mappers that write sorted, partitioned output on local disk. Reducers fetch their partitions, merge and sort, then reduce to final output written to HDFS. An optional combiner reduces shuffle data.
Explain in brief Data Flow technique of Map-Reduce Framework.
Data flow in MapReduce describes how data moves from the input in HDFS, through map, shuffle/sort and reduce, to the final output. The input is split, processed in parallel, and the intermediate results are redistributed by key.
HDFS input
|
[Split 1][Split 2][Split 3]
| | |
Mapper1 Mapper2 Mapper3 (local disk output)
| | |
Combiner Combiner Combiner (optional)
+---- Partition / Shuffle ----+
| |
sort+merge sort+merge
Reducer1 Reducer2
| |
part-r-00000 part-r-00001 (HDFS)
Steps
- Input splits: the job's input is divided into fixed-size splits (about one HDFS block). One map task is created per split. The
InputFormatandRecordReaderconvert records into (key, value) pairs. - Map: each mapper processes its split, ideally on the node that holds the block (data locality), and emits intermediate pairs. Output is buffered in memory (circular buffer), partitioned by reducer, sorted by key, and spilled to local disk. Spill files are merged into one partitioned, sorted file.
- Combiner (optional): it runs on map output before it is sent, to reduce the volume (e.g. local sum).
- Shuffle: each reducer fetches its partition from every mapper's output over the network (HTTP). Partitioning is
hash(key) mod R, which ensures all values of one key go to the same reducer. - Sort/merge: the reducer merges the fetched pieces, sorting them by key and grouping values with the same key.
- Reduce:
reduce(key, values)is called once per key group. - Output: results are written by
OutputFormatto HDFS, one file per reducer, and replicated.
Notes
- Intermediate data lives on local disks, not HDFS, to avoid replication cost.
- With zero reducers (map-only job), map output goes directly to HDFS.
- Failed tasks are re-run on another node using the same input split.
Small example (word count)
Two splits: "to be or" and "not to be".
- Mapper 1 emits (to,1) (be,1) (or,1); mapper 2 emits (not,1) (to,1) (be,1).
- Partitioner with two reducers sends to,be to one reducer and or,not to another (by hash).
- Reducer groups: be -> [1,1], to -> [1,1], or -> [1], not -> [1].
- Output: (be,2) (to,2) (or,1) (not,1).
Fault tolerance and locality in the flow
- The master schedules map tasks close to input blocks and re-runs failed map or reduce tasks.
- Completed map output on a failed node must be recomputed, because it is only on local disk.
- Reducers start copying map outputs as soon as maps complete, but the reduce function itself starts only after all maps finish.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Optimization and data locality in MapReduce · Big Data Technologies, chapter 3
- MapReduce worker failure tolerance · Big Data Technologies, chapter 3
- MapReduce workflow with example · Big Data Technologies, chapter 3 · asked 2×
- MapReduce max marks per college · Big Data Technologies, chapter 3
- Combiner function in MapReduce · Big Data Technologies, chapter 3
- Max and min word occurrence with MapReduce · Big Data Technologies, chapter 3
- MapReduce with GFS and HDFS · Information System, chapter 8
- MapReduce working with example · Information System, chapter 8
- Application framework versus component reuse · Software Engineering, chapter 5
- Stream flow from current meter data · Engineering Hydrology, chapter 4 · asked 2×