简体   繁体   English

如何在Azure redis缓存中修复此超时异常?

[英]How can I fix this timeout exception in Azure redis cache?

We have a web application which uses Microsoft.Web.Redis.RedisSessionStateProvider as the session state provider. 我们有一个Web应用程序,它使用Microsoft.Web.Redis.RedisSessionStateProvider作为会话状态提供程序。 We've had no problems with this until recently when suddenly the application is reporting a large number of exceptions as detailed below. 直到最近我们才突然发现应用程序报告了大量例外,我们对此没有任何问题,如下所述。

The message suggests some kind of timeout. 该消息表明某种超时。 But I've no idea how to resolve this. 但我不知道如何解决这个问题。 The application is an instance of Kentico CMS and we haven't customised its session caching mechanism in any way. 该应用程序是Kentico CMS的一个实例,我们没有以任何方式定制其会话缓存机制。

Main exception: 主要例外:

Message: 信息:

Exception of type 'System.Web.HttpException' was thrown. 抛出了类型'System.Web.HttpException'的异常。

Stack Trace: 堆栈跟踪:

at System.Web.HttpAsyncResult.End() 
at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) 

Inner exception: 内部异常:

Message: 信息:

Timeout performing EVAL, inst: 1, mgr: Inactive, err: never, queue: 0, qu: 0, qs: 0, qc: 0, wr: 0, wq: 0, in: 0, ar: 0, IOCP: (Busy=0,Free=1000,Min=2,Max=1000), WORKER: (Busy=3,Free=32764,Min=2,Max=32767), clientName: KSCOMAZUATWEB2 超时执行EVAL,inst:1,mgr:无效,错误:从不,队列:0,qu:0,qs:0,qc:0,wr:0,wq:0,in:0,ar:0,IOCP: (Busy = 0,Free = 1000,Min = 2,Max = 1000),WORKER :( Busy = 3,Free = 32764,Min = 2,Max = 32767),clientName:KSCOMAZUATWEB2

Stack Trace: 堆栈跟踪:

at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 1927 
at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\RedisBase.cs:line 80 
at StackExchange.Redis.RedisDatabase.ScriptEvaluate(String script, RedisKey[] keys, RedisValue[] values, CommandFlags flags) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\RedisDatabase.cs:line 866 
at Microsoft.Web.Redis.StackExchangeClientConnection.<>c__DisplayClass4.<Eval>b__3() in d:\TeamCityBuildAgent\work\f55792526e6d9089\src\Shared\StackExchangeClientConnection.cs:line 113 
at Microsoft.Web.Redis.StackExchangeClientConnection.RetryForScriptNotFound(Func`1 redisOperation) in d:\TeamCityBuildAgent\work\f55792526e6d9089\src\Shared\StackExchangeClientConnection.cs:line 129 
at Microsoft.Web.Redis.StackExchangeClientConnection.RetryLogic(Func`1 redisOperation) in d:\TeamCityBuildAgent\work\f55792526e6d9089\src\Shared\StackExchangeClientConnection.cs:line 155 
at Microsoft.Web.Redis.StackExchangeClientConnection.Eval(String script, String[] keyArgs, Object[] valueArgs) in d:\TeamCityBuildAgent\work\f55792526e6d9089\src\Shared\StackExchangeClientConnection.cs:line 113 
at Microsoft.Web.Redis.RedisConnectionWrapper.TryTakeWriteLockAndGetData(DateTime lockTime, Int32 lockTimeout, Object& lockId, ISessionStateItemCollection& data, Int32& sessionTimeout) in d:\TeamCityBuildAgent\work\f55792526e6d9089\src\RedisSessionStateProvider\RedisConnectionWrapper.cs:line 182 
at Microsoft.Web.Redis.RedisSessionStateProvider.GetItemFromSessionStore(Boolean isWriteLockRequired, HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actions) in d:\TeamCityBuildAgent\work\f55792526e6d9089\src\RedisSessionStateProvider\RedisSessionStateProvider.cs:line 272 
at Microsoft.Web.Redis.RedisSessionStateProvider.GetItemExclusive(HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actions) in d:\TeamCityBuildAgent\work\f55792526e6d9089\src\RedisSessionStateProvider\RedisSessionStateProvider.cs:line 190 
at System.Web.SessionState.SessionStateModule.GetSessionStateItem() 
at System.Web.SessionState.SessionStateModule.PollLockedSessionCallback(Object state) 

After experiencing the same issue and having read various posts on setting min & max thread values etc, it transpired that the issue was with the subscription tier. 在遇到相同的问题并阅读了有关设置最小和最大线程值等的各种帖子后,发现问题出在订阅层上。

C1 basic (£35/GBP mth) boasts a 1gb cache, 1000 concurrent connections which are exactly the same headline figures as the C1 Standard tier (£95GBP/Mth). C1 basic(£35 / GBP mth)拥有1gb缓存,1000个并发连接,这与C1标准层(£95GBP / Mth)完全相同。 It's a natural assumption that when you only require a few MB of cache and have only 50 concurrent sessions active at any point, that the C! 这是一个很自然的假设,当你只需要几MB的缓存并且在任何时候只有50个并发会话处于活动状态时,那就是C! basic would be adequate, if not overkill. 基本就足够了,如果不是矫枉过正的话。

The difference seems to be that C1 Basic works, if you have 10 or less concurrent users on your website. 如果您的网站上有10个或更少的并发用户,那么差异似乎是C1 Basic的工作原理。 In fairness, it is mentioned in the fine print that the basic is only suitable for development and testing environments. 公平地说,在细则中提到基本只适用于开发和测试环境。

I was just working through this on a client site and what helped me was to add this to the connection string of your provider: 我只是在客户端站点上完成此操作,帮助我的是将其添加到提供者的连接字符串中:

throwOnError="true" retryTimeoutInMilliseconds="500"

What I learned is sometimes there is a latency issue and if it doesn't resolve fast enough the default is to just "quit". 我所学到的有时会出现延迟问题,如果它解析得不够快,则默认只是“退出”。 So adding this allows it to continue to retry. 所以添加这个允许它继续重试。

Your string might look like this 你的字符串可能如下所示

<add name="MySessionStateStore" throwOnError="true" retryTimeoutInMilliseconds="500" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="mysite-prod.redis.cache.windows.net" accessKey="mykey" ssl="true" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM