创建表的时候
设置表的数据压缩
创建预分区
设置读取表中的数据不缓存
cache block
spark程序的优化
存在一个变量eventTypeList是Driver里面,filter是在Executor里面task运行
如果RDD有中3个分区,分别在不同的executor中,那么eventTypeList需要存储3份
在实际的开发中,一天处理的数据量几十个GB,分区有可能很多,一个数据库对应一个分区,一个分区对应一个Task,如果有1000个分区,
如果eventTypeList1M的话,将消耗1GB
可以考虑一个executor存储一份,如果有10个executor存储10M就好了
Spark supports two types of shared variables
spark提供2种方式变量共享
broadcast variables:广播变量
which can be used to cache a value in memory on all nodes,
使用广播变量将集合类别 广播出去:将数据发送到每一个executor里面
accumulators:累加器
which are variables that are only “added” to, such as counters and sums.