dip-data-analyze 使用的hiveserver 实践之 jvm调优

来源:互联网 发布:stm32编程教程 编辑:程序博客网 时间:2024/05/08 03:21

目前dip-data-analyze 正在运行的任务有 38个。其中5分钟任务有2个,小时任务有 20个以上,晚上执行的任务有 6个.任务并不多,都是使用hivesql 连接到hiveserver去执行。


本周曾经有2次 hiveserver 失效。现象表现为:进程在,但是不在接收任务,查看内存占用可以看到已经达到最大堆内存。


上面这些任务中有很多是要计算1小时日志 中服务器ip hits排名及用户分布数据,晚上的为将一天的用户分布数据进行合并成为一天的用户分布数据,有多个category在计算。


其中有1个category每小时日志量超过30g(该日志按5分钟一算,每5分钟 日志量为5~6g),有3个category每天日志量超过3g(日志量未全部过来,测试以后的实际计算方式,所以每小时算一次用户分布,其实是通过2步实现的,再凌晨进行合并)。


对该2次hiveserver 内存使用jstat 可以看到 byte数据一直维持在12g左右,hiveserver使用默认gc配置,-XX:NewRatio=2, gc策略为串行垃圾收集器。由于我们的任务按照计划去执行,而执行情况是 每个5分钟或10分钟点(00,05,10,15...),同时并发多个任务,每个任务如果是top分析的话,会涉及select  group by 操作,数据量会激增至g级,对内存是非常大的挑战。而hiveserver本身并没有及时去清除,几乎完全依赖gc机制。默认的新生代占用堆1/3的空间无法满足,导致年老代被频繁使用,而年老代 gc效率低,且选用gc策略不当,所以导致堆内存被耗尽,OOM,甚至不抛出OOM。


昨天晚上 优化了下gc的设置,最大最小堆内存都设置为15g,且-XX:NewRatio设为1, gc策略 -XX:+UseParallelGC -XX:ParallelGCThreads=20 -XX
:+UseParallelOldGC -XX:-UseGCOverheadLimit。


并且启动3个端口的hiveserver同时运行,dip-data-analyze在连接时 mod 3 来选择hiveserver,分散压力,目前系统稳定,但占用资源还是很高,在打出的gc日志中可以看到minal gc频率明显提高。

40739.404: [GC [PSYoungGen: 7258518K->608K(7679296K)] 7337701K->80110K(15359296K), 0.0037360 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032029_720230591.txt
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032030_1533384748.txt
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032031_1343894462.txt
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032032_1226993547.txt
40979.992: [GC [PSYoungGen: 7249181K->544K(7679296K)] 7328684K->80358K(15359296K), 0.0044220 secs] [Times: user=0.02 sys=0.00, real=0.00 secs] 
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032033_842220648.txt
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032034_1280980357.txt
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032035_1941524784.txt
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032036_1561833501.txt
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032037_489060756.txt
41279.171: [GC [PSYoungGen: 7156104K->544K(7679296K)] 7235918K->80678K(15359296K), 0.0175880 secs] [Times: user=0.11 sys=0.00, real=0.02 secs] 
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032038_1935162195.txt
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032039_1116976889.txt
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032040_387691925.txt
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032041_373956757.txt
41519.301: [GC [PSYoungGen: 7248721K->544K(7679296K)] 7328856K->80998K(15359296K), 0.0035890 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032042_172953787.txt
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032043_1244513021.txt
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032044_100594148.txt
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032045_428742374.txt
Hive history file=/tmp/hdfs/hive_job_log_hdfs_201112032046_2103451161.txt
41819.830: [GC [PSYoungGen: 7258820K->544K(7679296K)] 7339275K->81318K(15359296K), 0.0318180 secs] [Times: user=0.25 sys=0.00, real=0.03 secs]


目前占用情况如图,基本稳定在这个状态。



后面还需要深入对hiveserver研究,优化hiveserver


append ...


最后 jvm arg 修改为 :

export HADOOP_OPTS="$HADOOP_OPTS  -Xms5000m -Xmn4000m -XX:MaxNewSize=4000m -Xss128k  -XX:MaxHeapFreeRatio=80 -XX:MinHeapFreeRatio=40 -XX:+UseParNewGC -XX:+UseConcMarkSw
eepGC -XX:CMSInitiatingOccupancyFraction=70 -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0 -XX:-UseGCOverheadLimit -XX:MaxTenuringThreshold=8 -XX:P
ermSize=800M -XX:MaxPermSize=800M -XX:GCTimeRatio=19 -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps"


稳定下来,平均内存占用为2.3g