Redis交互速度很慢,达到几十到一百毫秒一次,且压力测试下经常报错:
org.springframework.data.redis.RedisSystemException: Redis exception; nested exception is io.lettuce.core.RedisException: Connection closedat org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:74)at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:41)at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:44)at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:42)at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:277)at org.springframework.data.redis.connection.lettuce.LettuceConnection.await(LettuceConnection.java:1085)at org.springframework.data.redis.connection.lettuce.LettuceConnection.lambda$doInvoke$4(LettuceConnection.java:938)at org.springframework.data.redis.connection.lettuce.LettuceInvoker$Synchronizer.invoke(LettuceInvoker.java:673)at org.springframework.data.redis.connection.lettuce.LettuceInvoker$DefaultSingleInvocationSpec.get(LettuceInvoker.java:589)at org.springframework.data.redis.connection.lettuce.LettuceKeyCommands.exists(LettuceKeyCommands.java:79)at org.springframework.data.redis.connection.DefaultedRedisConnection.exists(DefaultedRedisConnection.java:81)at org.springframework.data.redis.core.RedisTemplate.lambda$hasKey$7(RedisTemplate.java:782)at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:224)at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:191)at org.springframework.data.redis.core.RedisTemplate.hasKey(RedisTemplate.java:782)at com.bestdata.em.drs.util.RedisUtil.hasKey(RedisUtil.java:98)at com.bestdata.em.drs.receive.serivce.impl.HasMoreBusinessServiceImpl.insertFormulaValueToMongoDB(HasMoreBusinessServiceImpl.java:180)at com.bestdata.em.drs.receive.serivce.impl.HasMoreBusinessServiceImpl.moreBusinessOperations(HasMoreBusinessServiceImpl.java:113)at com.bestdata.em.drs.receive.serivce.FormulaDataProcessingService.sensorFormulaCalculation(FormulaDataProcessingService.java:264)at com.bestdata.em.drs.receive.serivce.FormulaDataProcessingService.run(FormulaDataProcessingService.java:167)at java.lang.Thread.run(Thread.java:750)
16:18:33.404 [FormulaThreadPoll-9] ERROR c.b.e.d.r.s.i.HasMoreBusinessServiceImpl - Unite Alarm Exception:Redis exception; nested exception is io.lettuce.core.RedisException: Connection closed
问题排查:服务端和redis是否在同一网段
是内网,没问题
问题排查:Redis资源占用
执行top命令
Redis CPU占用一直高达50%~100%,3到5秒就跳一次(此时生产环境有其他程序和redis交互,但是没有特别大)
Redis数据量占用很高,且这是单点部署非集群模式
执行压力测试程序(频繁交互Redis,经常报错RedisSystemException):Redis CPU占用一直高达100%
优化思路
提高Redis服务器资源配置
Redis改为集群部署模式,分担压力