记录调优压测某项~
使用Jmeter压测工具发生了Redis堆外内存溢出现象
查看原因,发现springboot在2.0后默认使用lettuce操作redis客户端,它使用netty通信,lettuce的bug导致堆外内存溢出,底层实现是只要有操作,会统计内存使用量,操作完会decrement减内存,可能是lettuce客户端在减内存的过程出错
lettuce的bug导致netty堆外内存溢出 列如:JVM内存大小设置 -Xmx300m
; netty如果没有指定堆外内存,默认使用JVM设置的 -Xmx300m
也可以通过-Dio.netty.maxDirectMemory进行设置lettuce的内存大小,但不推荐,随着使用时长也会继续发生堆外内存溢出。
解决方案:
不能使用-Dio.netty.maxDirectMemory 只去调大堆外内存!
1、升级lettuce客户端。
2、切换使用jedis
<!-- 引入redis-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
评论区