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. Spring定时器XML配置

    spring-task.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=&qu ...

  2. SQL OUTER JOIN

    When we want to select out all the record from two table, no matter it's present at second table or ...

  3. C++对C的改进(2)

    本文地址:http://www.cnblogs.com/archimedes/p/cpp-change2.html,转载请注明源地址 区别一:原型声明的区别 原型声明的概念: 函数要先定义再使用,如果 ...

  4. java垃圾回收机制--可达性算法

    先说一些题外话,Java虚拟机在执行Java程序的过程中会把它所管理的内存划分为若干个不同的数据区,这些区分为线程私有区和线程共享区 1.线程私有区 a.程序计数器 记录正在执行的虚拟机字节码指令地址 ...

  5. document.getElementsByName和document.getElementById用法

    本文的问题在国外的一个网站得到了答案http://stackoverflow.com/questions/11235409/no-getelementbyid-for-body document.bo ...

  6. url: (6) Couldn’t resolve host ‘www.ttlsa.com’

    http://www.ttlsa.com/linux/curl-6-couldnt-resolve-host/ 2. 解决问题 尝试解决方法: 修改dns # cat /etc/resolv.conf ...

  7. Android调用OCR识别图像中的文字

    // CharacterExtractor.java // Copyright (c) 2010 William Whitney // All rights reserved. // This sof ...

  8. 【BIRT】01_在win10上安装BIRT

    环境:windows 10 64位 安装文件:链接:https://pan.baidu.com/s/1vYGbB0D1QeQ923oIIdoI9Q 密码:qcde 说明:安装文件也可以自己去官网下载, ...

  9. JSP 九大隐式对象

    final javax.servlet.jsp.PageContext pageContext; javax.servlet.http.HttpSession session = null; fina ...

  10. 将web容器置于OSGi框架下进行web应用的开发

    将web容器置于OSGi框架下,其实就是将web容器做成OSGi支持的Bundle,再安装到OSGi框架中,这里使用的是Jetty容器. 1.创建一个Eclipse插件项目,在此插件下创建一个WebR ...