【发布时间】:2021-04-03 22:50:27
【问题描述】:
.Net core 2.1 web-api 使用下面的 redis nuget 包“StackExchange.Redis” Version="2.1.55" 并连接到 Azure Redis P1 层,Redis 版本 4.0.14
在 appsettings.config 上,
“RedisConfiguration”:{ "ConnectionString": "mycache.redis.cache.windows.net:6380,密码=$$$$$$$$$F543shkerXXXXXg=,ssl=True,abortConnect=False", “数据库编号”:1 }
在执行负载测试时,
非常频繁地收到以下异常,尤其是在保持 50 个请求/秒时。我们的应用程序部署在具有 3 个节点的 Azure 服务结构集群上。在任何服务器节点上都没有观察到处理器/内存压力。
Message":"将值设置为缓存时出现 Redis 异常:未知 写入时发生错误 message","Level":"Error","ExceptionType":"StackExchange.Redis.RedisConnectionException
"Message":"从缓存中获取值时出现 Redis 异常:An 写入时发生未知错误 message","Level":"Error","ExceptionType":"StackExchange.Redis.RedisConnectionException" 完整的堆栈跟踪供您参考:
“堆栈跟踪”:“在 StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](消息 消息,ResultProcessor1 处理器,ServerEndPoint 服务器)在 //src/StackExchange.Redis/ConnectionMultiplexer.cs:line 2800\r\n at StackExchange.Redis.RedisBase.ExecuteSync[T](消息消息, ResultProcessor1 处理器,ServerEndPoint 服务器)在 //src/StackExchange.Redis/RedisBase.cs:第 54 行\r\n at MyApplication.RedisCacheAdapter.c__DisplayClass21_1.b__0() 在 M:\work2\7ae5cc7915b5f803\MyApplication\RedisCacheAdapter.cs:line 199\r\n 在 Polly.Policy.c__DisplayClass144_0.b__0(上下文 ctx, CancellationToken ct)\r\n at Polly.RetrySyntax.c__DisplayClass5_1.b__1(上下文 ctx, CancellationToken ct)\r\n 在 Polly.Retry.RetryEngine.Implementation[TResult](Func3 动作,上下文 上下文,CancellationToken 取消令牌,IEnumerable1 shouldRetryExceptionPredicates, IEnumerable1 shouldRetryResultPredicates, Func1 policyStateFactory)\r\n at Polly.RetrySyntax.c__DisplayClass5_0.b__0(Action2 动作, 上下文上下文,CancellationToken cancelToken)\r\n at Polly.Policy.ExecuteInternal(Action2 动作,上下文上下文, CancellationToken cancelToken)\r\n 在 Polly.Policy.Execute(Action2 动作,上下文上下文, CancellationToken cancelToken)\r\n 在 MyApplication.RedisCacheAdapter.Put(String key, Byte[] bytes, TimeSpan 到期时间)在 M:\work2\7ae5cc7915b5f803\MyApplication\RedisCacheAdapter.cs:line 196","Exception":"写入时出现未知错误 message","LoggerName":"MyApplication.RedisCacheAdapter","Message":"Redis 将值设置为缓存时出现异常:发生未知错误 写的时候 message","Level":"Error","ExceptionType":"StackExchange.Redis.RedisConnectionException"`
出现此类错误的原因是什么以及如何修复此“StackExchange.Redis.RedisConnectionException”? redis 连接字符串属性的任何更改或 redis 版本更新会有用吗?
有时,在 3 个节点集群上维持 50 个请求/秒时也会出现低于异常超时异常
"Message":"Redis Timeout 异常发生。
【问题讨论】:
标签: azure asp.net-core-webapi azure-redis-cache