1. No. thats the purpose of broadcast variable, ie not to be shipped with every task. From Documentation
Broadcast Variables Broadcast variables allow the programmer to keep a read-only variable cached on each machine rather than shipping a copy of it with tasks. They can be used, for example, to give every node a copy of a large input dataset in an efficient manner. Spark also attempts to distribute broadcast variables using efficient broadcast algorithms to reduce communication cost. After the broadcast variable is created, it should be used instead of the value v in any functions run on the cluster so that v is not shipped to the nodes more than once. In addition, the object v should not be modified after it is broadcast in order to ensure that all nodes get the same value of the broadcast variable (e.g. if the variable is shipped to a new node later). 2. See above :) If you need what you are asking for, you are looking for closures. Best Ayan On Sat, May 30, 2015 at 4:11 PM, bit1...@163.com <bit1...@163.com> wrote: > > Can someone help take a look at my questions? Thanks. > > ------------------------------ > bit1...@163.com > > > *From:* bit1...@163.com > *Date:* 2015-05-29 18:57 > *To:* user <user@spark.apache.org> > *Subject:* How Broadcast variable works > Hi, > I have a spark streaming application. SparkContext uses broadcast > vriables to broadcast Configuration information that each task will be used > > I have following two questions: > 1. Will the broadcast variable be broadcasted every time when driver sends > tasks to workers in each batch interval? > 2. If the above question is true, then if the broadcast variable is > modified between the batch interval(The configuration information is > updated over time) and Spark Context broadcasts it again, will tasks see > the updated variable? > > Thanks. > > > > ------------------------------ > bit1...@163.com > > -- Best Regards, Ayan Guha