【十八掌●武功篇】第十掌:参数mapreduce.job.reduce.slowstart.completedmaps

之前我所见到的hive语句在执行mapreduce job的时候,打印的日志都是当map执行到100%的时候,再执行reduce。今天在执行hive sql的时候发现map还没有执行完成,reduce任务就开始。如下图所示:

这里写图片描述

开始不知道原因,后来经过度娘,发现原来在mapred-site.xml配置文件中有一个参数mapreduce.job.reduce.slowstart.completedmaps,这个参数可以控制当map任务执行到哪个比例的时候就可以开始为reduce task申请资源。

默认配置:

<property>
    <name>
         mapreduce.job.reduce.slowstart.completedmaps
    </name>
    <value>
        0.05
    </value>
    <description>
        Fraction of the number of maps in the job which should be complete before reduces are scheduled for the job.
     </description>
</property>

默认配置为0.05,那么map task在执行到5%的时候就开始为reduce进行申请资源,开始执行reduce操作,reduce可以开始进行拷贝map结果数据和做reduce shuffle操作。

在之前都是map执行到100%才开始执行reduce操作,是因为mapreduce.job.reduce.slowstart.completedmaps这个参数设置为1。

配置多少才合适呢?

mapreduce.job.reduce.slowstart.completedmaps这个参数如果设置的过低,那么reduce就会过早地申请资源,造成资源浪费;如果这个参数设置的过高,比如为1,那么只有当map全部完成后,才为reduce申请资源,开始进行reduce操作,实际上是串行执行,不能采用并行方式充分利用资源。

如果map数量比较多,一般建议提前开始为reduce申请资源。

参数源码分析

mapreduce.job.reduce.slowstart.completedmaps 参数源码分析

发布了74 篇原创文章 · 获赞 74 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/chybin500/article/details/80417534