【问题标题】:StackExchange.Redis is timing out since connecting to Azure RedisStackExchange.Redis 在连接到 Azure Redis 后超时
【发布时间】:2016-12-03 11:04:38
【问题描述】:

异常消息:超时执行 GET allBots,inst:1,mgr: 不活动,err:从不,队列:7,qu:0,qs:7,qc:0,wr:0,wq:0,in: 65536,ar:0,IOCP:(忙=2,空闲=998,最小=1,最大=1000),工人: (忙=0,空闲=2047,最小=1,最大=2047)

执行 GET stock_by_symbol_leg.to 超时,inst:1,mgr: 不活动,err:从不,队列:13,qu:0,qs:13,qc:0,wr:0,wq:0, 在:0,ar:0,IOCP:(忙=3,空闲=997,最小=1,最大=1000),工人: (忙=3,空闲=2044,最小=1,最大=2047)

执行 GET stock_by_symbol_aapl 超时,inst:1,mgr:不活动, 错误:从不,队列:13,qu:0,qs:13,qc:0,wr:0,wq:0,in:0,ar: 0,IOCP:(忙=3,空闲=997,最小=1,最大=1000),工人: (忙=3,空闲=2044,最小=1,最大=2047)

执行 GET 超时 portefoliosBotById_ec030000-0001-1200-0000-000000000000, inst: 1, mgr:不活动,err:从不,队列:13,qu:0,qs:13,qc:0,wr:0,wq: 0, in: 0, ar: 0, IOCP: (Busy=3,Free=997,Min=1,Max=1000), WORKER: (忙=3,空闲=2044,最小=1,最大=2047)

我正在使用 StackExchange.Redis 版本 1.1.603 和可用的最小 Azure 实例。我收到很多 GET/SET 超时错误。当我在本地使用我的盒子上的 Redis 服务器时,我没有这个问题,这让我倾向于在 Azure 上解决问题。 Redis中存储的信息大约2kb到10kb。

在 Azure 门户上,我看到我的连接数低于 20,内存使用量在 130meg 左右,cpu 使用率低于 35%,Redis 服务器负载始终低于 13%。我没有从门户中看到任何问题的迹象。

知道在哪里可以获得更多信息来解决这个问题吗?

编辑

自从我第一次发帖以来,我改进了一些设置。

1) 我从 C0 传递到 Azure Redis 的 C1 实例。

2) 我将连接字符串更改为 15 秒超时。这是它的外观:

boursexxxxxxx.windows.net:6380,password=xxxxxxxx,ssl=True,abortConnect=False,connectRetry=5, connectTimeout=15000, synctimeout=15000"

3) 我创建了一个包含 10 个延迟加载 ConnectionMultiplex 的池,我在每次调用时都会轮换。

private static readonly Lazy<ConnectionMultiplexer>[] lazyConnection;

//In the static constructor of my cache :

lock (lockPookRoundRobin)
{
                lazyConnection = new Lazy<ConnectionMultiplexer>[POOL_SIZE];
                var connectionStringCache = System.Configuration.ConfigurationManager.AppSettings["CacheConnectionString"];
                for (int i = 0; i < POOL_SIZE; i++)
                {
                    lazyConnection[i] = new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect(connectionStringCache));
                }
}

4) 我减少了许多缓存的值。根据我拥有的序列化对象:

4.1) 1.25ko (5%)

4.2) 0.154ko (5%)

4.3) 26ko (20%)

4.4) 700ko(这里我们需要努力,但仅限于

4.5) 5ko (30%)

4.6) 66ko (40%)

【问题讨论】:

    标签: stackexchange.redis azure-redis-cache


    【解决方案1】:

    您的 ThreadPool 设置似乎需要调整为 described here

    您可能还想查看这些文章,它们将帮助您了解人们在使用 Redis 时遇到的常见问题:

    【讨论】:

    • 很好的信息来源。我有大部分。我会将 Azure 从 Basic 增加到标准大小(即使它非常昂贵)。我将尝试拥有一个 ConnectionMultiplexer 池。我会尽快写回我的结果。
    【解决方案2】:

    对于正在阅读该帖子的每个人。我做了几件事:

    • 如果您使用的是实体框架,请务必限制 你在序列化过程中的深度。
    • 压缩序列化的字符串。
    • 使用 C1 代替 C0。
    • 添加大量遥测来查找频率 设置和从缓存中获取,优化重场景。
    • 在 IIS 上使用内存缓存缓存 Redis 缓存。我做了一件很 小,但正在释放需要大量数据的案例的压力。

    在云上,Redis 与 Web 服务不在同一台服务器上会增加大量开销。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-12
      • 2019-09-28
      • 1970-01-01
      • 2022-11-13
      • 1970-01-01
      • 2020-04-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多