来源:https://www.iteblog.com/archives/1907.htmlphp
在使用 Apache Spark 的时候,做业会以分布式的方式在不一样的节点上运行;特别是当集群的规模很大时,集群的节点出现各类问题是很常见的,好比某个磁盘出现问题等。咱们都知道 Apache Spark 是一个高性能、容错的分布式计算框架,一旦它知道某个计算所在的机器出现问题(好比磁盘故障),它会依据以前生成的 lineage 从新调度这个 Task。html
咱们如今来考虑下下面的场景:node
上面提到的场景其实对咱们人来讲能够经过某些措施来避免。可是对于 Apache Spark 2.2.0 版本以前是没法避免的,不太高兴的是,来自 Cloudera 的工程师解决了这个问题:引入了黑名单机制 Blacklist(详情能够参见SPARK-8425,具体的设计文档参见Design Doc for Blacklist Mechanism),而且随着 Apache Spark 2.2.0 版本发布,不过目前还处于实验性阶段。算法
黑名单机制实际上是经过维护以前出现问题的执行器(Executors)和节点(Hosts)的记录。当某个任务(Task)出现失败,那么黑名单机制将会追踪这个任务关联的执行器以及主机,并记下这些信息;当在这个节点调度任务出现失败的次数超过必定的数目(默认为2),那么调度器将不会再将任务分发到那台节点。调度器甚至能够杀死那台机器对应的执行器,这些均可以经过相应的配置实现。app
咱们能够经过 Apache Spark WEB UI 界面看到执行器的状态(Status):若是执行器处于黑名单状态,你能够在页面上看到其状态为 Blacklisted ,不然为 Active。以下图所示:框架
目前黑名单机制能够经过一系列的参数来控制,主要以下:分布式
参数 | 默认值 | 含义 |
---|---|---|
spark.blacklist.enabled | false | 若是这个参数这为 true,那么 Spark 将再也不会往黑名单里面的执行器调度任务。黑名单算法能够由其余“spark.blacklist”配置选项进一步控制,详情参见下面的介绍。 |
spark.blacklist.timeout | 1h | (实验性) How long a node or executor is blacklisted for the entire application, before it is unconditionally removed from the blacklist to attempt running new tasks. |
spark.blacklist.task.maxTaskAttemptsPerExecutor | 1 | (实验性) For a given task, how many times it can be retried on one executor before the executor is blacklisted for that task. |
spark.blacklist.task.maxTaskAttemptsPerNode | 2 | (实验性) For a given task, how many times it can be retried on one node, before the entire node is blacklisted for that task. |
spark.blacklist.stage.maxFailedTasksPerExecutor | 2 | (实验性) How many different tasks must fail on one executor, within one stage, before the executor is blacklisted for that stage. |
spark.blacklist.stage.maxFailedExecutorsPerNode | 2 | (实验性) How many different executors are marked as blacklisted for a given stae, before the entire node is marked as failed for the stage. |
spark.blacklist.application.maxFailedTasksPerExecutor | 2 | (实验性) How many different tasks must fail on one executor, in successful task sets, before the executor is blacklisted for the entire application. Blacklisted executors will be automatically added back to the pool of available resources after the timeout specified by spark.blacklist.timeout . Note that with dynamic allocation, though, the executors may get marked as idle and be reclaimed by the cluster manager. |
spark.blacklist.application.maxFailedExecutorsPerNode | 2 | (实验性) How many different executors must be blacklisted for the entire application, before the node is blacklisted for the entire application. Blacklisted nodes will be automatically added back to the pool of available resources after the timeout specified by spark.blacklist.timeout . Note that with dynamic allocation, though, the executors on the node may get marked as idle and be reclaimed by the cluster manager. |
spark.blacklist.killBlacklistedExecutors | false | (实验性) If set to "true", allow Spark to automatically kill, and attempt to re-create, executors when they are blacklisted. Note that, when an entire node is added to the blacklist, all of the executors on that node will be killed. |
由于黑名单机制目前还处于实验性状态,因此上面的一些参数可能会在后面的 Spark 中有所修改。性能