MapReduce的shuffle过程

沙诺 posted @ 2012年10月15日 15:38 in 云计算 , 7069 阅读

MapReduce的核心是shuffle,她对于mapreduce的效率起到了至关重要的作用,now,我把我对shuffle的理解过程简单介绍一下,如果有误还请指教阿。。

MapReduce的过程(针对一个map来说):

每个Map在内存中都有一个缓存区,map的输出结果会先放到这个缓冲区当中,缓冲区有一个spill percent,这里默认是80%(可以手动进行配置),也就是说当输出到缓冲区中的内容达到80%时,就会进行spill(溢出),溢出到磁盘的一个临时文件中,也就是说这80%的内容成为一个临时文件,这里还涉及到了一个partition的概念,一个临时文件里面是进行了分区的,并且分区的数量由reduce的数量决定,即不同的分区内容传给不同的reduce。当这80%的内容在溢出时,map会继续向那20%的缓冲中输出。插入一点,在缓冲区溢出到磁盘之前,会进行sort和combiner,然后才会写道磁盘中。这两个步骤很重要,尤其是combiner,它直接决定了MapReduce的效率。并且sort和combiner这两个处理发生在在shuffle的整个过程中。这样一个map执行下来,就会在磁盘上存储几个临时文件,然后会对这几个临时文件进行一个merge,合并程一个文件,这个文件中有n个partition,n是reduce的数量。说明一下:这些临时文件和合并的文件都是在本地文件系统上存储的。

每个Map输出这样一个文件,最后不同Map生成的文件按照不同的partition传给不同的reduce,然后reduce直接把结果输出到HDFS文件系统上了。

这个是官方的一个图:

有人认为这个图有问题,但在我个人开来,这个图描述的没有问题,如果认为确实有问题的还请指教阿。。

简单说一下combiner的一个很重要的作用:combiner会对相同key的值进行合并,比如<a,1><a,1><a,1>,combiner过后合并成<a,3>,即减少了数据量,那末传向reduce的数据量就减少了,进而提高了效率。。

Avatar_small
commercial cleaning 说:
2021年8月27日 22:50

Cleaning your personal home and cleaning professionally are two very surprising things. Despite the fact that you clean your home continually, figuring out how to clean professionally takes a ton of time and effort––when a customer pays for your administrations,

Avatar_small
part time maids in d 说:
2021年8月31日 21:15

you need to remember that cleaning companies are not maid services. They will not jump up and do your dishes and walk your dog and pick up your dirty socks. You need to do all of this beforehand. They will take care of everything else. If you need your carpet cleaned and they offer that service, they will do it. If you need your floor mopped and cleaned, they will do it. But it's up to you to make sure that it are at least a little bit swept up. If you are older in age, you may want to enlist aid from a friend or someone else that you trust to help you tidy up before hand. However, leave the rest to the cleaning company-they're there to help.

Avatar_small
monthly maid service 说:
2023年8月12日 00:20

Your own investigations are really a critical fine element to investigate before employing you or group that you perform cleaning services for your needs. This exploration will provide essential data to the lawful state of housecleaning faculty to guarantee that they will be lawful occupants in the room, ready for work legitimately. Historical verification will equally deliver statistics about conceivable criminal history records. Abstain right from procuring anybody by having a criminal capture.

Avatar_small
monthly cleaning ser 说:
2024年1月31日 23:47

As soon as you finalize the particular maids the ultimate way to go concerning housekeeping companies is undertake a strategy. You should be aware of what you are likely to tackle and also what you are likely to do with all the items you will find you can do without. If you will find you don't use something in your everyday life and which you have not within useful inside past 3-6 weeks, consider getting it inside the toss/done stack.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter