1.观察gc日志发现young gc日志很长
2020-01-18T11:01:46.486+0800: 10670069.343: [GC2020-01-18T11:01:54.876+0800: 10670077.733: [ParNew: 1119126K->770K(1258304K), 0.0078630 secs] 3377296K->2258940K(4054528K), 8.3983450 secs] [Times: user=0.05 sys=0.05, real=8.40 secs]
Heap after GC invocations=445687 (full 9):par new generation total 1258304K, used 770K [0x00000006fae00000, 0x0000000750350000, 0x0000000750350000)eden space 1118528K, 0% used [0x00000006fae00000, 0x00000006fae00000, 0x000000073f250000)from space 139776K, 0% used [0x000000073f250000, 0x000000073f310890, 0x0000000747ad0000)to space 139776K, 0% used [0x0000000747ad0000, 0x0000000747ad0000, 0x0000000750350000)concurrent mark-sweep generation total 2796224K, used 2258170K [0x0000000750350000, 0x00000007fae00000, 0x00000007fae00000)concurrent-mark-sweep perm gen total 77656K, used 46556K [0x00000007fae00000, 0x00000007ff9d6000, 0x0000000800000000)
2.通过grafana查看资源使用,io负载高
3.参考文档分析原因
YoungGC 停顿超长时间
https://blog.csdn.net/taoy86/article/details/79746652
young gc时间过长可能是应为记录gc日志的操作被系统的io给阻塞了
4.解决方法
方案一:
将gc的日志记录到内存文件系统(/dev/shm)避免io阻塞
缺点:因为使用内存文件系统,重启时记录丢失
方案二:
单独为gc日志准备一个硬盘,或者SSD(高速硬盘)