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:7077spark.default.parallelism          10spark.driver.memory                2gspark.serializer                   org.apache.spark.serializer.KryoSerializerspark.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.

spark通过合理设置spark.default.parallelism参数提高执行效率相关推荐

  1. Spark中的spark.sql.shuffle.partitions 和spark.default.parallelism参数设置默认partition数目

    当不跟随父对象partition数目的shuffle过程发生后,结果的partition会发生改变,这两个参数就是控制这类shuffle过程后,返回对象的partition的 经过实测,得到结论: s ...

  2. 从spark.default.parallelism参数来看Spark并行度、并行计算任务概念

    1 并行度概念理解 并行度:并行度= partition= task总数.但是同一时刻能处理的task数量由并行计算任务决定(CPU cores决定). 并行度(Parallelism)指的是分布式数 ...

  3. Spark调优之 -- Spark的并行度深入理解(别再让资源浪费了)

    1. 并行度理解  Spark作业中,各个stage的task的数量,代表Spark作业在各个阶段stage的并行度. 分为资源并行度(物理并行度)和数据并行度(逻辑并行度) 在Spark Appli ...

  4. spark重要参数调优建议:spark.default.parallelism设置每个stage默认的task数量

    spark.default.parallelism 参数说明:该参数用于设置每个stage的默认task数量.这个参数极为重要,如果不设置可能会直接影响你的Spark作业性能. 参数调优建议:Spar ...

  5. 谈谈spark.sql.shuffle.partitions和 spark.default.parallelism 的区别及spark并行度的理解

    谈谈spark.sql.shuffle.partitions和 spark.default.parallelism 的区别及spark并行度的理解 spark.sql.shuffle.partitio ...

  6. spark.sql.shuffle.partitions 和 spark.default.parallelism 的区别

    在关于spark任务并行度的设置中,有两个参数我们会经常遇到,spark.sql.shuffle.partitions 和 spark.default.parallelism, 那么这两个参数到底有什 ...

  7. 关于Spark默认并行度spark.default.parallelism的理解

    spark.default.parallelism是指RDD任务的默认并行度,Spark中所谓的并行度是指RDD中的分区数,即RDD中的Task数. 当初始RDD没有设置分区数(numPartitio ...

  8. streaming优化:spark.default.parallelism调整处理并行度

    官方是这么说的: Cluster resources can be under-utilized if the number of parallel tasks used in any stage o ...

  9. spark任务优先级设置:spark.yarn.priority

    Spark对于Yarn priority的支持源码详解 Yarn的调度器 在Yarn中,提供了Capacity scheduler和Fair scheduler,它们都支持priority的.这里我们 ...

  10. spark 写mysql 设置主键_Spark Sql 连接mysql

    1.基本概念和用法(摘自spark官方文档中文版) Spark SQL 还有一个能够使用 JDBC 从其他数据库读取数据的数据源.当使用 JDBC 访问其它数据库时,应该首选 JdbcRDD.这是因为 ...

最新文章

  1. IIS7错误:不能在此路径中使用此配置节。如果在父级别上锁定了该节,便会出现这种情况。锁定是默认设置的(overrideModeDefault=Deny).........
  2. SQL 简单,复杂查询,基本函数查询
  3. 发明个人计算机哪国人,电脑是哪国人发明的,发明的人是谁??
  4. nvme通用驱动_对领域驱动设计的理解与实践
  5. linux vim 到底,真的有(很多)linux大牛用vim写项目吗?
  6. 在Linux中快速找到文件的几种方法
  7. golang延时_Golang 定时器底层实现深度剖析
  8. 爬虫文件存储-2:MongoDB
  9. Spring定时任务@Scheduled提前一秒执行
  10. atitit.修复xp 操作系统--重装系统--保留原来文件不丢失
  11. badboy设置中文_录制脚本badboy工具使用手册
  12. 基于UML的面向对象软件开发过程
  13. 北理工乐学C语言 60.合并排序
  14. 切比雪夫(Chebyshev)不等式
  15. python+django+layUI+MySQL+TSC打印机搭建4G设备管理平台项目(二)——过程中的难点记录
  16. Pytorch中transforms.Compose()的使用
  17. console用法java_Java Console printf(String, Object)用法及代码示例
  18. Python爬取新冠肺炎疫情实时数据(丁香园)
  19. 如何成为一名合格的程序员?
  20. ❤ 挑战C站最强C++ STL标准库总结(内含大量示例)

热门文章

  1. 阶段3 2.Spring_05.基于XML的IOC的案例1_2 基于XML的IOC的案例-编写spring的Ioc配置
  2. [Swift]LeetCode311. 稀疏矩阵相乘 $ Sparse Matrix Multiplication
  3. go语言-csp模型-并发通道
  4. NOIP2015题解
  5. 大型架构之科普工具篇
  6. 第13周 本周个人总结
  7. 黑马day11 脏读数据amp;解
  8. Android(java)学习笔记51:ScrollView用法
  9. JAVA环境变量的配置方法【希望可以帮助你】【个人实测没问题】
  10. PHP书写规范 PHP Coding Standard