.NET 6应用使用StackExchange.Redis执行SET操作时周期性超时求助
周期性StackExchange.Redis SET超时问题求助
我是StackOverflow新手,遇到问题前来求助:我有一个.NET 6应用,使用StackExchange.Redis 2.2.4库存储键值到运行在Rocky Linux 8.8系统的自建Redis服务中,应用会周期性出现以下超时错误:
Timeout performing SET (5000ms), next: SET testKey, inst: 7, qu: 0, qs: 894, aw: False, rs: ReadAsync, ws: Idle, in: 0, in-pipe: 0, out-pipe: 0, serverEndpoint: <My Redis Server>, mc: 1/1/0, mgr: 10 of 10 available, clientName: <My Client Name>, IOCP: (Busy=0,Free=1000,Min=8,Max=1000), WORKER: (Busy=47,Free=32720,Min=800,Max=32767), v: 2.2.4.27433 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)
我的观察:qs值表明有大量操作在等待Redis worker回复,但WORKER仅显示47个处于忙碌状态。
问题仅周期性出现,我已在.NET应用中配置Azure Application Insight并捕获到相关异常:
我检查了/etc/redis下的调试日志,未发现任何错误:
21675:M 19 Oct 2023 18:42:21.285 . 24 clients connected (0 replicas), 24262392 bytes in use 21675:M 19 Oct 2023 18:42:26.303 - DB 0: 2 keys (2 volatile) in 4 slots HT. 21675:M 19 Oct 2023 18:42:26.304 - DB 2: 380 keys (324 volatile) in 512 slots HT. 21675:M 19 Oct 2023 18:42:26.304 . 24 clients connected (0 replicas), 24221448 bytes in use 21675:M 19 Oct 2023 18:42:31.323 - DB 0: 2 keys (2 volatile) in 4 slots HT. 21675:M 19 Oct 2023 18:42:31.323 - DB 2: 378 keys (322 volatile) in 512 slots HT. 21675:M 19 Oct 2023 18:42:31.323 . 24 clients connected (0 replicas), 24220936 bytes in use 21675:M 19 Oct 2023 18:42:36.041 * 100 changes in 300 seconds. Saving... 21675:M 19 Oct 2023 18:42:36.047 * Background saving started by pid 24143 24143:C 19 Oct 2023 18:42:36.051 - Fork CoW for RDB: current 0 MB, peak 0 MB, average 0 MB 21675:M 19 Oct 2023 18:42:36.348 - DB 0: 2 keys (2 volatile) in 4 slots HT. 21675:M 19 Oct 2023 18:42:36.349 - DB 2: 378 keys (322 volatile) in 512 slots HT. 21675:M 19 Oct 2023 18:42:36.349 . 24 clients connected (0 replicas), 24220936 bytes in use 24143:C 19 Oct 2023 18:42:36.349 * DB saved on disk 24143:C 19 Oct 2023 18:42:36.350 * Fork CoW for RDB: current 6 MB, peak 6 MB, average 3 MB 21675:M 19 Oct 2023 18:42:36.449 * Background saving terminated with success
另外,问题发生时Redis所在服务器的CPU和磁盘使用率均无异常:CPU最高不超过30%,磁盘使用率仅13%。
以下是应用中Redis实例的构造代码,我在整个应用中复用了同一个实例:
try { var connections = RedisConnectionFactory.GetConnections(); foreach (var connection in connections) { Database = connection.GetDatabase(2); var endpoints = connection.GetEndPoints(); Server = connection.GetServer(endpoints.First()); // Test connection try { SetKeyStringValue("testKey", "testValue", TimeSpan.FromSeconds(10)); break; } catch { } } } catch { }
恳请各位提供帮助,谢谢!
内容的提问来源于stack exchange,提问作者EternalGod
相关产品推荐
相关产品推荐

