(1)创建表的时候
设置表的数据压缩
创建与分区
设置读取表中的数据不缓存
(2)Spark程序的优化
.filter(tuple =>eventTypeList.contains(EventEnum.valueOfAlias(tuple._1)))
(ps : 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.
Spark序列化优化
在官方文档中推荐使用的 Kryo 序列化,相比于Java 序列化,性能更优
并且是强烈推荐使用Kryo序列化的
(3)使用HFileOutputFile
向HBASE表中存储数据的时候,
put方式
putData ->WAL->MemStore ->StoreFile(HFile)
Hfile方式
Date –>Hfile ->load table