1.创建表的时候
设置表的数据压缩
创建预分区
设置读取表中的数据不缓存
2.spark程序的优化
.filter(tuple =>eventTypeList.contains(EventEnum.valueOfAlias(tuple._1)))
eventTypeList是Driver里面,filter是在Executor里面task运行
如果是一个数据库对应一个分区,一个分区对应一个Task,假设有1000个分区
如果eventTypeList1M的话,将消耗1GB
可以考虑一个executor存储一份,如果有10个executor存储10M就好了
Spark supports two types of shared variables
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.
3.使用HFileOuputFile
向HBASE表中存储数据的时候
put方式
putData ->WAL->MemStore ->StoreFile(HFile)
Hfile方式
Date –>Hfile ->load table
本文探讨了在Spark中优化程序执行效率的方法,包括利用广播变量减少数据传输消耗,以及在向HBase存储数据时采用HFileOutputFormat以提高写入性能。同时,介绍了在创建表时设置数据压缩、预分区及禁用数据缓存等策略。
685

被折叠的 条评论
为什么被折叠?



