spark中有partition的概念(和slice是同一个概念,在spark1.2中官网已经做出了说明),一般每个partition对应一个task。在我的测试过程中,如果没有设置spark.default.parallelism参数,spark计算出来的partition非常巨大,与我的cores非常不搭。我在两台机器上(8cores *2 +6g * 2)上,spark计算出来的partition达到2.8万个,也就是2.9万个tasks,每个task完成时间都是几毫秒或者零点几毫秒,执行起来非常缓慢。在我尝试设置了 spark.default.parallelism 后,任务数减少到10,执行一次计算过程从minute降到20second。

参数可以通过spark_home/conf/spark-default.conf配置文件设置。

eg.

spark.master  spark://master:7077

spark.default.parallelism  10

spark.driver.memory  2g

spark.serializer  org.apache.spark.serializer.KryoSerializer

spark.sql.shuffle.partitions  50

下面是官网的相关描述:

from:http://spark.apache.org/docs/latest/configuration.html

Property Name Default Meaning
spark.default.parallelism For distributed shuffle operations like reduceByKey and join, the largest number of partitions in a parent RDD. For operations likeparallelize with no parent RDDs, it depends on the cluster manager:

  • Local mode: number of cores on the local machine
  • Mesos fine grained mode: 8
  • Others: total number of cores on all executor nodes or 2, whichever is larger
Default number of partitions in RDDs returned by transformations like joinreduceByKey, and parallelize when not set by user.

from:http://spark.apache.org/docs/latest/tuning.html

Level of Parallelism

Clusters will not be fully utilized unless you set the level of parallelism for each operation high enough. Spark automatically sets the number of “map” tasks to run on each file according to its size (though you can control it through optional parameters to SparkContext.textFile, etc), and for distributed “reduce” operations, such as groupByKey and reduceByKey, it uses the largest parent RDD’s number of partitions. You can pass the level of parallelism as a second argument (see the spark.PairRDDFunctions documentation), or set the config propertyspark.default.parallelism to change the default. In general, we recommend 2-3 tasks per CPU core in your cluster.

原文地址:http://www.cnblogs.com/wrencai/p/4231966.html

Parallelism , Partitioner的更多相关文章

  1. Concurrency != Parallelism

    前段时间在公司给大家分享GO语言的一些特性,然后讲到了并发概念,大家表示很迷茫,然后分享过程中我拿来了Rob Pike大神的Slides <Concurrency is not Parallel ...

  2. Hadoop学习笔记—9.Partitioner与自定义Partitioner

    一.初步探索Partitioner 1.1 再次回顾Map阶段五大步骤 在第四篇博文<初识MapReduce>中,我们认识了MapReduce的八大步凑,其中在Map阶段总共五个步骤,如下 ...

  3. parallelism

    COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION Traditionally, the co ...

  4. Concurrency vs. Parallelism

    http://getakka.net/docs/concepts/terminology Terminology and Concepts In this chapter we attempt to ...

  5. Max Degree of Parallelism最大并行度配置

    由于公司的业务在急速增长中,发现数据库服务器已经基本撑不住这么多并发.一方面,要求开发人员调整并发架构,利用缓存减少查询.一方面从数据库方面改善并发.数据库的并行度可设置如下: 1)cost thre ...

  6. MapReduce中的分区方法Partitioner

    在进行MapReduce计算时,有时候需要把最终的输出数据分到不同的文件中,比如按照省份划分的话,需要把同一省份的数据放到一个文件中:按照性别划分的话,需要把同一性别的数据放到一个文件中.我们知道最终 ...

  7. Spark自定义分区(Partitioner)

    我们都知道Spark内部提供了HashPartitioner和RangePartitioner两种分区策略,这两种分区策略在很多情况下都适合我们的场景.但是有些情况下,Spark内部不能符合咱们的需求 ...

  8. MapReduce框架Partitioner分区方法

    前言:对于二次排序相信大家也是似懂非懂,我也是一样,对其中的很多方法都不理解诶,所有只有暂时放在一边,当你接触到其他的函数,你知道的越多时你对二次排序的理解也就更深入了,同时建议大家对wordcoun ...

  9. Partitioner没有被调用的情况

    map的输出,通过分区函数决定要发往哪个reducer. 有2种情况,我们自定义的Partitioner不会被调用 1) reducer个数为0 这种情况,没有reducer,不需要分区 2) red ...

随机推荐

  1. C#应用视频教程2.3 OPENGL虚拟仿真介绍

    本节最重要的一个内容,就是让视野可以平移+旋转+缩放(就像打CS游戏一样以第一人称视角去观察物体,如果可能的话W,S,A,D四个按键控制人物移动,还有鼠标控制视角),本节最重要的一个概念就是设置观察视 ...

  2. vue的全家桶

    自定义指令 <div v-demo="{ color: 'white', text: 'hello!' }"></div> Vue.directive('d ...

  3. css实现九宫格

    原理:浮动+margin负边距 示例代码: <!DOCTYPE html> <html lang="zh"> <head> <meta c ...

  4. com.tongyan.tutelage:bdservice_v1

    3-21 10:14:20.833 2892-2892/? E/art: No implementation found for long com.baidu.platform.comjni.map. ...

  5. 解决github push错误The requested URL returned error: 403 Forbidden while accessing(转)

    github push错误: git push error: The requested URL returned error: 403 Forbidden while accessing https ...

  6. 从缓存行出发理解volatile变量、伪共享False sharing、disruptor

    volatilekeyword 当变量被某个线程A改动值之后.其他线程比方B若读取此变量的话,立马能够看到原来线程A改动后的值 注:普通变量与volatile变量的差别是volatile的特殊规则保证 ...

  7. 解析_theme_build_registry()和_theme_process_registry()

    Drupal使用_theme_build_registry()和_theme_process_registry()两个函数构建theme registry.theme registry是theme h ...

  8. [Verilog]随意整数(奇数,偶数)分频器设计, 50%占空比

    module div_clk(clk_in, divisor, clk_out); input clk_in; input divisor; output clk_out; reg clk_out = ...

  9. Java入门到精通——调错篇之Eclipse No Java virtual machine was found after searching the following locations

    一.错误现象. 在一次启动Eclipse的时候弹出了以下的错误 二.错误原因 原因是没有找到javaw.exe文件的路径. 三.解决方式 在eclipse根文件夹下找到eclipse.ini增加以下一 ...

  10. 【TP3.2与TP5.0区别】

    Tp3.2 和 Tp5.0之间的区别   5.0版本和之前版本的差异较大,本篇对熟悉3.2版本的用户给出了一些5.0的主要区别. URL和路由 5.0的URL访问不再支持普通URL模式,路由也不支持正 ...