HBase MapReduce与Speculative Task

来源:互联网 发布:javascript 服务端 编辑:程序博客网 时间:2024/06/06 00:41

Speculative Task(推测式任务)是mapreduce框架中一个比较重要的优化策略。当某个server某个时间段处于忙碌状态而无法快速完成某个task(当然也可能是server本身性能低下),从而拖延了整个job的完成进度,此时若启用Speculative Task策略,jobtacker会为执行慢的task启动speculative task,多个相同的任务同时运行,哪个task先运行完,则采用该task的执行结果,并同时kill掉执行慢的task。这样做能尽量减少执行慢的task带来的性能拖延。但同时Speculative Task也会带来负面影响。即启动了多余的task,会耗掉server更多的资源,对于资源吃紧的集群来说应该尽量不启用。关于Speculative Task更具体的介绍请参考Hadoop中Speculative Task调度策略。

 

而HBase框架中,map/reduce在操作HBase的时候会尽量采用本地策略(优先本地数据),即每个task所在的tasktracker会尽可能与它所计算数据所在的regionserver在同一个server上。所以多启动一个speculative task(此时数据肯定不在本地)只会增加io,网络等资源的消耗,不会带来实质性的性能优化。所以HBase官方文档上也强烈建议关闭speculative task来避免资源的浪费。

 

It is generally advisable to turn off speculative execution for MapReduce jobs that use HBase as a source. This can either be done on a per-Job basis through properties, on on the entire cluster. Especially for longer running jobs, speculative execution will create duplicate map-tasks which will double-write your data to HBase; this is probably not what you want.


关闭Speculative task有两种方式,一种是在mapred-site.xml文件中配置

<property><name>mapred.map.tasks.speculative.execution</name><value>false</value></property><property><name>mapred.reduce.tasks.speculative.execution</name><value>false</value></property>

默认情况下这两个配置都是true,处于开启状态。

另外一种方法是在提交job的时候在程序中设置,如

jobconf.set("mapred.map.tasks.speculative.execution",false);jobconf.set("mapred.reduce.tasks.speculative.execution",false);