Wednesday, July 31, 2013

Map Reduce: For my sophomore



Yash: Dad, What is Map Reduce?

Me: Ok!! Give me context.

Yash: Alex was talking about it and saying, Google invented this thing. What is Map Reduce? Is it something to do with Google Glasses?

Me: It has nothing to do with Google Glass. It is an algorithm to do lot of work in short duration using parallel processing.

GJ: Boys food is ready. Come to dinner table.

Me: Let’s eat food and we will talk there.

At dinner table.

Yash: So what is Map Reduce?

Me: Ok let us talk about food first. Tell me how she prepares a curry.

Yash: For every curry there is separate recipe. She follows that recipe.

Me: hmm…

Me: But there should be some very high level steps, she must be following in each recipe.

Yash: Oh yes. She follows few steps in each preparation.


  • Wash the vegetables
  • Chop the vegetables
  • Prepares masala (combination of spices)
  • Put everything into pan and then fry and simmer.


Me: Very good. But if she needs to cook food for 50 persons, how she will do?

Yash: She will take your and mine help. I can wash the vegetables. You can do chop job. She can prepare masala. If we all three work parallel, she can cook in less time.

Me: Excellent. Now she has to cook curry for 300 persons. What to do?

Yash: We need to hire help to do the job.

Me: How?

Yash: Say we hire 12 people. First 3 hires can start washing vegetables.  Once we have sufficient vegetables to start chopping job, next 4 hires will start chopping job. In parallel another 3 hires can start preparing masala. Last 2 hires can combine masala and chopped vegetables and start frying and simmering.

Me: Fantastic!! Now you know map Reduce.

Yash: I didn’t get it.

Me: Let us put preparing curry in Map Reduce context. As you explained first three batches of hires will be doing parallel work of washing, chopping and masala preparation. This is Map, where lot of parallel work is happening. Last batch of hires will combine the output of previous batches and do the frying and simmering job. This is Reduce part. Here work from Map part are combined and fed into another process.

Give a paper napkin. Let me put this into picture.





Yash: It has nothing to do with Google Glass.

Me: Yes. Map Reduce has nothing to do with Google Glass or ant programming language. You can implement Map reduce in any programming language. Even you can implement Map Reduce to situations where you have nothing to do with computers.



1 comment: