executor

Kafka集成SparkStreaming

有些话、适合烂在心里 提交于 2019-11-28 15:04:00
Spark Streaming + Kafka集成指南 Kafka项目在版本0.8和0.10之间引入了一个新的消费者API,因此有两个独立的相应Spark Streaming包可用。请选择正确的包, 请注意,0.8集成与后来的0.9和0.10代理兼容,但0.10集成与早期的代理不兼容。 注意:从Spark 2.3.0开始,不推荐使用Kafka 0.8支持。 Spark Streaming从Kafka接收数据,转换为spark streaming中的数据结构Dstream。数据接收方式有两种 :1 使用Receiver接收的旧方法:2使用Direct拉取的新方法(在Spark 1.3中引入)。 https://spark.apache.org/docs/1.6.3/streaming-kafka-integration.html https://spark.apache.org/docs/2.3.1/streaming-kafka-0-10-integration.html Receiver方式 Received是使用Kafka高级Consumer API实现的。与所有接收器一样,从Kafka通过Receiver接收的数据存储在Spark Executor的内存中,然后由Spark Streaming启动的job来处理数据。然而默认配置下,这种方式可能会因为底层的失败而丢失数据

spark 内存溢出处理

对着背影说爱祢 提交于 2019-11-28 12:43:38
简介 Spark中的OOM问题不外乎以下两种情况 map执行中内存溢出 shuffle后内存溢出 map执行中内存溢出代表了所有map类型的操作。包括:flatMap,filter,mapPatitions等。 shuffle后内存溢出的shuffle操作包括join,reduceByKey,repartition等操作。 后面先总结一下我对Spark内存模型的理解,再总结各种OOM的情况相对应的解决办法和性能优化方面的总结。如果理解有错,希望在评论中指出。 Spark 内存模型 Spark在一个Executor中的内存分为三块,一块是execution内存,一块是storage内存,一块是other内存。 execution内存是执行内存,文档中说join,aggregate都在这部分内存中执行,shuffle的数据也会先缓存在这个内存中,满了再写入磁盘,能够减少IO。其实map过程也是在这个内存中执行的。 storage内存是存储broadcast,cache,persist数据的地方。 other内存是程序执行时预留给自己的内存。 execution和storage是Spark Executor中内存的大户,other占用内存相对少很多,这里就不说了。 在spark-1.6.0以前的版本,execution和storage的内存分配是固定的,使用的参数配置

Difference between Executors.newFixedThreadPool(1) and Executors.newSingleThreadExecutor()

我怕爱的太早我们不能终老 提交于 2019-11-28 10:55:12
My question is : does it make sense to use Executors.newFixedThreadPool(1)?? . In two threads (main + oneAnotherThread) scenarios is it efficient to use executor service?. Is creating a new thread directly by calling new Runnable(){ } better than using ExecutorService?. What are the upsides and downsides of using ExecutorService for such scenarios? PS: Main thread and oneAnotherThread dont access any common resource(s). I have gone through : What are the advantages of using an ExecutorService? . and Only one thread at a time! assylias does it make sense to use Executors.newFixedThreadPool(1) ?

Spark架构角色及基本运行流程

泄露秘密 提交于 2019-11-28 10:38:14
1. 集群角色 Application :基于spark的用户程序,包含了 一个Driver program 和集群中 多个Executor Driver Program :运行application的main()函数并自动创建SparkContext。Driver program通过一个SparkContext对象来访问Spark,通常用SparkContext代表Driver。 SparkContext : Spark的主要入口点,代表对计算集群的一个连接,是整个应用的上下文,负责与ClusterManager通信,进行资源申请、任务的分配和监控等。 ClusterManager :在集群上获得资源的外部服务(spark standalone,mesos,yarm), Standalone模式 :Spark原生的资源管理, 由Master负责 资源, YARN模式 : Yarn中的ResourceManager Worker Node :集群中任何可运行Application代码的节点,负责控制计算节点,启动Executor或者Driver(Standalone模式:Worder,Yarn模式:NodeManager) Executor : 为某个Application在worker node上执行任务的一个进程 ,该进程负责运行task并负责将数据存储在内存或者硬盘上

Running a task in parallel to another task

我只是一个虾纸丫 提交于 2019-11-28 10:32:54
I have the following Foo class that uses FooProcessor class. So what i want to do is, while running cp1 instance process method, in parallel I want to run cp2.process() . public class Foo { public static void main(String [] args){ FooProcessor cp1 = new FooProcessor(); FooProcessor cp2 = new FooProcessor(); cp1.process(); // in parallel process cp2.process(); } } public class FooProcessor { public void process(){ System.out.println("Processing.."); } } However, i want cp1 sequentially, so i want it to run and complete, if cp2 doesnt complete or fails it is fine. If it doenst fail i want to

axios取消功能的设计与实现

自古美人都是妖i 提交于 2019-11-28 09:57:07
取消功能的设计与实现 # 需求分析 有些场景下,我们希望能主动取消请求,比如常见的搜索框案例,在用户输入过程中,搜索框的内容也在不断变化,正常情况每次变化我们都应该向服务端发送一次请求。但是当用户输入过快的时候,我们不希望每次变化请求都发出去,通常一个解决方案是前端用 debounce 的方案,比如延时 200ms 发送请求。这样当用户连续输入的字符,只要输入间隔小于 200ms,前面输入的字符都不会发请求。 但是还有一种极端情况是后端接口很慢,比如超过 1s 才能响应,这个时候即使做了 200ms 的 debounce,但是在我慢慢输入(每个输入间隔超过 200ms)的情况下,在前面的请求没有响应前,也有可能发出去多个请求。因为接口的响应时长是不定的,如果先发出去的请求响应时长比后发出去的请求要久一些,后请求的响应先回来,先请求的响应后回来,就会出现前面请求响应结果覆盖后面请求响应结果的情况,那么就乱了。因此在这个场景下,我们除了做 debounce,还希望后面的请求发出去的时候,如果前面的请求还没有响应,我们可以把前面的请求取消。 从 axios 的取消接口设计层面,我们希望做如下的设计: const CancelToken = axios.CancelToken; const source = CancelToken.source(); axios.get('/user

Container killed by YARN for exceeding memory limits

我们两清 提交于 2019-11-28 09:48:32
19/08/12 14:15:35 ERROR cluster.YarnScheduler: Lost executor 5 on worker01.hadoop.mobile.cn: Container killed by YARN for exceeding memory limits. 5 GB of 5 GB physical memory used. Consider boosting spark.yarn.executor.memoryOverhead. 在看这个问题之前,首先解释下下面参数的含义: hadoop yarn-site.xml部分资源定义相关参数,更详细的内容可参考 官网链接 yarn.nodemanager.resource.memory-mb //每个NodeManager可以供yarn调度(分配给container)的物理内存,单位MB yarn.nodemanager.resource.cpu-vcores //每个NodeManager可以供yarn调度(分配给container)的vcore个数 yarn.scheduler.maximum-allocation-mb //每个container能够申请到的最大内存 yarn.scheduler.minimum-allocation-mb //每个container能够申请到的最小内存

Spark 知识点总结--调优(一)

久未见 提交于 2019-11-28 09:40:40
搭建集群: SPARK_WORKER-CORES : 当计算机是32核双线程的时候,需要指定SPARK_WORKER_CORES的个数为64个 SPARK_WORKER_MEMORY : 任务提交: ./spark-submit --master node:port --executor-cores --class ..jar xxx --executor-cores: 指定每个executor使用的core 的数量 --executor-memory: 指定每个executor最多使用的内存 --total-executor-cores: standalone 集群中 spark application 所使用的总的core --num-executor : 在yarn 中为 spark application 启动的executor --Driver-cores: driver使用的core --Driver-memory: driver使用的内存 以上的参数是在spark-submit 提交任务的时候指定的,也可以在spark-defaults.xml中进行配置 spark 并行度调优: (一般在做测试的时候使用) sc.textFile(xx,minnum) sc.parallelize(seq,num) sc.makeRDD(seq,num) sc

Executor and Daemon in Java

僤鯓⒐⒋嵵緔 提交于 2019-11-28 08:31:38
I have a MyThread object which I instantiate when my app is loaded through the server, I mark it as a Daemon thread and then call start() on it. The thread is meant to sit and wait for information from a queue as long as the application is active. My problem/question is this: Currently MyThread is extending Thread because I mark it as Daemon and I read about how it's more prefferable to implement Runnable and to use Executors. So what I wanted to ask is if MyThread will implement Runnable instead of extending Thread (and of course will be renamed) and I'll use newSingleThreadScheduledExecutor(

Executor suitable for non thread-safe code

你。 提交于 2019-11-28 08:15:10
问题 I am developing some code that will eventually be multithreaded, using a thread pool Executor. The tasks executed by the thread pool will make call-backs and (sometimes) submit further tasks to the task queue. I would like to develop the code single threaded first, get it right (I'm using Test Driven Development) and only then make the alterations to ensure thread safety (locks, etc). To do that, I need an Executor that is safe to use with non thread-safe code. I think that means I need an