Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache spark Spark中存储的广播变量在哪里?_Apache Spark_Broadcasting - Fatal编程技术网

Apache spark Spark中存储的广播变量在哪里?

Apache spark Spark中存储的广播变量在哪里?,apache-spark,broadcasting,Apache Spark,Broadcasting,根据官方文件,“广播变量允许程序员在每台机器上缓存一个只读变量,而不是将其副本与任务一起发送” 让我们假设在我的spark submit命令中,我将-num执行器设置为10。我的集群是2节点集群,现在假设5个执行器在节点1中启动,下5个执行器在节点2中启动 scala> val broadcastVar = sc.broadcast(Array(1, 2, 3)) broadcastVar: org.apache.spark.broadcast.Broadcast[Array[Int]]

根据官方文件,“广播变量允许程序员在每台机器上缓存一个只读变量,而不是将其副本与任务一起发送”

让我们假设在我的spark submit命令中,我将-num执行器设置为10。我的集群是2节点集群,现在假设5个执行器在节点1中启动,下5个执行器在节点2中启动

scala> val broadcastVar = sc.broadcast(Array(1, 2, 3))
broadcastVar: org.apache.spark.broadcast.Broadcast[Array[Int]] = Broadcast(0)
根据doc,该broadcastVar是否在每个执行器的存储内存中可用,因此这意味着broadcastVar可以作为10个副本使用


是否该广播变量将在每个节点的磁盘内存中可用。因此,两个节点各获得一个broadcastVar副本,因此从每个节点运行的所有执行器都可以获取该broadcastVar?

查看广播在类中的实现方式:

因此,每个执行者都有自己的副本,由其BlockManager管理


同样代表累加器变量。

查看广播是如何在类中实现的:

因此,每个执行者都有自己的副本,由其BlockManager管理


相同表示累加器变量。

Ok。这意味着,如果我们设置10个执行器,那么将有10个广播变量的副本。对吗?算上司机的原件,一共有11份。好的。这意味着,如果我们设置10个执行器,那么将有10个广播变量的副本。对吗?算上司机的原件“复印件”,总共有11份。
The driver divides the serialized object into small chunks and
stores those chunks in the BlockManager of the driver.

On each executor, the executor first attempts to fetch the object from its BlockManager. If
it does not exist, it then uses remote fetches to fetch the small chunks from the driver and/or
other executors if available. Once it gets the chunks, it puts the chunks in its own
BlockManager, ready for other executors to fetch from. we can see that broadcast variables are stored in executor's BlockManager