Stackexchange.Redis超时&套接字故障 [英] Stackexchange.Redis timeouts & socketfailures

查看:126
本文介绍了Stackexchange.Redis超时&套接字故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Azure Redis(使用Stackexchange.Redis)作为缓存存储,并且通常可以正常工作.但是我时不时地遇到超时错误,而且我无法确定发生这种情况的原因.

I am using Azure Redis (using Stackexchange.Redis) as a cache storage and its generally working fine. But I am getting timeouts errors now and then and I can't nail down why it is happening.

我的Redis连接设置:

My redis connection settings:

value="dev.redis.cache.windows.net,ssl=true,password=secret,abortConnect=false,syncTimeout=3000"

我在同一秒(多次调用)中得到了所有这些异常:[我也在GET操作中得到了这些异常.几乎所有这些异常都在StringSet&上.StringGet.我很少在HashSets或HashGets上遇到异常]

I am getting all these exception in the same second (multiple calls): [I get these on GET operations aswell. Almost all these exceptions are on StringSet & StringGet. I rarely get exceptions on HashSets or HashGets]

Timeout performing SET {key}, inst: 1, mgr: ExecuteSelect, queue: 6, qu=0, qs=6, qc=0, wr=0/0, in=0/0
SocketFailure on SET
SocketFailure on SET
No connection is available to service this operation: SET 

我猜测设置该对象所花费的时间比预期的长,这可能是由于该对象较大,所以我可能会增加synctimeout,但这会隐藏其他一些问题吗?

I am guessing that setting the object is taking longer than expected, this could be due to the object being large so I could potentially increase the synctimeout but would that be hiding some other problem?

我仅在对stackexchange.redis的同步调用中获得这些异常,但在异步调用时没有看到异常.

I am only getting these exceptions on synchronous calls to stackexchange.redis, I have not seen an exception when the call is asynchronous.

Stacktrace:

Stacktrace:

StackExchange.Redis.RedisConnectionException: SocketFailure on SET
   at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) i
   at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) 
   at StackExchange.Redis.RedisDatabase.StringSet(RedisKey key, RedisValue value, Nullable`1 expiry, When when, CommandFlags flags) 
at calling method

我正在使用StackExchange.Redis 1.0.414程序包,并且正在使用MessagePack序列化我的对象

I am using StackExchange.Redis 1.0.414 package and I am using MessagePack to serialize my objects

推荐答案

超时通常是由以下几种原因之一引起的.这是一些例子

Timeouts are typically caused by one of a few things. Here are some examples

  1. 客户端或服务器的CPU达到100%
  2. 配置不佳的ThreadPool设置,并增加流量
  3. 客户端向服务器发送昂贵的命令.
  4. 最大化网络带宽(在客户端或服务器上)

有关客户端问题的提示: https://gist.github.com/JonCole/db0e90bedeb3fc4823c2

Tips for Client side issues: https://gist.github.com/JonCole/db0e90bedeb3fc4823c2

有关服务器端问题的提示: https://gist.github.com/JonCole/9225f783a40564c9879d

Tips for server side issues: https://gist.github.com/JonCole/9225f783a40564c9879d

我建议您也升级到新版本的StackExchange.Redis.版本1.1.603在超时错误消息中有一些更详细的诊断信息,这些信息可以帮助您识别一些我上面列出的常见客户端内容.

I would recommend upgrading to a newer version of the StackExchange.Redis also. Version 1.1.603 has some more detailed diagnostic info in the timeout error message that may help you identify some of common client-side the things I listed above.

对于Socket故障,我看到的客户端与服务器之间的连接断开有两个常见原因:

As for Socket failures, a couple of common causes for connection drops between the client and server that I have seen are:

  1. 扩展客户端-在Azure中扩展客户端应用程序时,我看到了简短的客户端连接问题.
  2. 修补Redis时,将出现一些连接闪烁.此处说明了Azure Redis修补程序: https://gist.github.com/JonCole/317fe03805d5802e31cfa37e646e419d

这篇关于Stackexchange.Redis超时&套接字故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆