我们正在使用 Redisson 连接到具有 1 个主节点和 2 个副本节点的 AWS elasticache 上的复制 Redis。
该应用程序使用多个RLocalCachedMaps、Locks 和几千个Topics来跟踪用户状态。(随着用户在线和离线,主题和订阅来来去去)。
然而,我们经常得到一系列RedisTimeoutExceptions,最初这些是在服务器运行了几天之后并且会持续发生直到服务器重新启动,或者会因内存不足错误而崩溃。这让我认为这是缺乏可用的订阅,但是如果我正确理解它们,我们的设置(如下)应该支持超过 100,000 个订阅并且我们还没有接近。
此外,其中一些会在预热期间发生,服务器上的负载相对较轻,经过几次异常连接后,几天都没有大问题,这表明这不是纯粹的订阅问题。命令每次都是简单的锁定/发布/订阅,而不是复杂的批处理。
AWS Elasticache 节点上的负载始终很小,我们的服务器部署在 AWS EC2 实例上,因此应该具有相对良好的连接性!
我们在数量上获得的 2 个例外是锁定或订阅主题:
Caused by: org.redisson.client.RedisTimeoutException: Subscribe timeout: (7500ms)
at org.redisson.command.CommandAsyncService.syncSubscription(CommandAsyncService.java:142) ~[redisson-3.8.2.jar!/:na]
at org.redisson.RedissonLock.lockInterruptibly(RedissonLock.java:149) ~[redisson-3.8.2.jar!/:na]
at org.redisson.RedissonLock.lockInterruptibly(RedissonLock.java:136) ~[redisson-3.8.2.jar!/:na]
at org.redisson.RedissonLock.lock(RedissonLock.java:118) ~[redisson-3.8.2.jar!/:na]
Run Code Online (Sandbox Code Playgroud)
和
java.util.concurrent.CompletionException: org.redisson.client.RedisTimeoutException
at org.redisson.misc.RedissonPromise.await(RedissonPromise.java:197) ~[redisson-3.8.2.jar!/:na]
at org.redisson.misc.RedissonPromise.await(RedissonPromise.java:206) ~[redisson-3.8.2.jar!/:na]
at org.redisson.command.CommandAsyncService.syncSubscription(CommandAsyncService.java:141) ~[redisson-3.8.2.jar!/:na]
at org.redisson.RedissonTopic.addListener(RedissonTopic.java:133) ~[redisson-3.8.2.jar!/:na]
at org.redisson.RedissonTopic.addListener(RedissonTopic.java:109) ~[redisson-3.8.2.jar!/:na]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_111]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_111]
at …Run Code Online (Sandbox Code Playgroud)