堆栈交换redis客户端超时

lhcgjxsq  于 2021-06-09  发布在  Redis
关注(0)|答案(0)|浏览(293)

我正在努力弄清楚stack exchange redis客户端的错误消息告诉我什么:
未处理的异常:system.aggregateexception:发生一个或多个错误(等待响应超时(出站=0kib,入站=0kib,经过32516ms,超时30000ms),inst:0,qu:0,qs:1,in:0,serverendpoint:unspecified/:6379,mgr:9/10可用,clientname:yyy,iocp:(忙=0,空闲=1000,最小=2,最大=1000),worker:(忙=1025,空闲=31742,最小=1024,最大=32767),v:2.0.571.20511(请参阅本文,了解一些可能导致超时的常见客户端问题:https://stackexchange.github.io/stackexchange.redis/timeouts))--->stackexchange.redis.redistimeoutexception:等待响应超时(出站=0kib,入站=0kib,经过32516ms,超时30000ms),inst:0,qu:0,qs:1,in:0,serverendpoint:未指定/:6379,mgr:9/10可用,clientname:yyy,iocp:(busy=0,free=1000,min=2,max=1000),worker:(busy=1025,free=31742,min=1024,max=32767),v:2.0.571.20511(请参阅本文了解一些可能导致超时的常见客户端问题:https://stackexchange.github.io/stackexchange.redis/timeouts
我用这段代码选择负载最少的连接多路复用器并退出,但在触发大量字符串集命令时仍会超时。

public class RedisConnectionManager : IRedisConnectionManager
{
    private const int MaxQueueLength = 10;
    private readonly List<Lazy<ConnectionMultiplexer>> _connectionMultiplexers;

    public RedisConnectionManager(List<Lazy<ConnectionMultiplexer>> connectionMultiplexers)
    {
        this._connectionMultiplexers = connectionMultiplexers;
    }

    public async Task<ConnectionMultiplexer> GetLeastBusyConnectionAsync()
    {
        var leastBusyConnection = this._connectionMultiplexers.OrderBy(connection => connection.Value.GetCounters().Interactive.TotalOutstanding).First();
        await WaitUntilConnectionAvailableAsync(leastBusyConnection);
        return this._connectionMultiplexers.OrderBy(connection => connection.Value.GetCounters().Interactive.TotalOutstanding).First().Value;
    }

    private static async Task WaitUntilConnectionAvailableAsync(Lazy<ConnectionMultiplexer> leastBusyConnection)
    {
        while (leastBusyConnection.Value.GetCounters().Interactive.TotalOutstanding > MaxQueueLength)
        {
            await Task.Delay(100);
        }
    }
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题