难道火花读取HDFS的数据,并在同一时间做一些计算? [英] Is it possible that spark read HDFS data and do some computation at the same time?

查看:137
本文介绍了难道火花读取HDFS的数据,并在同一时间做一些计算?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我运行星火平台上以下工作计数应用程序:

For example, I run a the following work count application on the Spark platform:

val textFile = sc.textFile("hdfs://...")
val counts = textFile.flatMap(line => line.split(" "))
             .map(word => (word, 1))
             .reduceByKey(_ + _)
counts.saveAsTextFile("hdfs://...")

和假设有一个工人需要处理1Gb的数据,那么是有可能,这个工作人员会获取所有1Gb的数据之前,就开始做一些计算(如flatMap)?

And assume there is one worker need to handle 1Gb data, then is it possible that this worker will start doing some computation(like flatMap) before fetching all 1Gb data ?

推荐答案

一般来说,是的,它可以,但还没有你的问题有些宽泛。所以我不知道你在寻找一个答案为特定的情况下,还是不行。

Generally speaking, yes it can, but yet your question a bit broad. So I don't know you are looking for an answer for a specific case or not.

在一个给定的应用程序的Spark(SparkContext实例),多个并行作业可以,如果他们来自不同的线程提交的同时运行。通过工作,我的意思是星火的动作(例如保存,收集),并在需要运行,以评估行动的任何任务。星火的调度完全线程安全的,并支持该用例,使服务于多个请求(例如,用于多用户查询)应用程序。

Inside a given Spark application (SparkContext instance), multiple parallel jobs can run simultaneously if they were submitted from separate threads. By "job", I mean a Spark action (e.g. save, collect) and any tasks that need to run to evaluate that action. Spark’s scheduler is fully thread-safe and supports this use case to enable applications that serve multiple requests (e.g. queries for multiple users).

有时你需要不同的用户之间共享资源。

Sometimes you need to share resource between different users.

在默认情况下,星火的调度运行在FIFO的方式工作。每个作业分为阶段和第一份工作对所有可用资源得到优先权,而它的阶段有任务的推出,那么如果在队列的头部作业不需要使用第二个作业获得优先权,等等。整个集群,以后的作业就可以开始马上运行,但如果在队列的头部的作业大,则以后作业可能被显著延迟

By default, Spark’s scheduler runs jobs in FIFO fashion. Each job is divided into "stages" and the first job gets priority on all available resources while its stages have tasks to launch, then the second job gets priority, etc. If the jobs at the head of the queue don’t need to use the whole cluster, later jobs can start to run right away, but if the jobs at the head of the queue are large, then later jobs may be delayed significantly.

通常一切都取决于您所使用的调度程序和什么意图。

Usually everything depends on the scheduler that you use and for what intent.

参考。官方文件>作业调度>调度中的应用程序


  • 所以要回您的具体问题的并假设有一个工人需要处理1Gb的数据,那么是有可能,这个工人将获取所有1Gb的数据之前,就开始做一些计算(如flatMap)?

是会的。

这篇关于难道火花读取HDFS的数据,并在同一时间做一些计算?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆