ServiceStack.Redis:无法连接:sPort: [英] ServiceStack.Redis: Unable to Connect: sPort:

查看:396
本文介绍了ServiceStack.Redis:无法连接:sPort:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常得到
ServiceStack.Redis:无法连接:sPort:0或ServiceStack.Redis:无法连接:sPort:50071(或其他端口号)。

I regularly get ServiceStack.Redis: Unable to Connect: sPort: 0 or ServiceStack.Redis: Unable to Connect: sPort: 50071 (or another port number).

这似乎是在我们的网站繁忙时发生的。 Redis本身看起来很好,CPU或内存使用量并未真正增加。

This appears to happen when our site is busier. Redis itself appears fine, no real increase in CPU or memory usage.

我正在使用连接池,并尝试更改超时值而没有成功。

I'm using connection pooling and have tried changing the timeout values without success.

public sealed class RedisConnection
{
    // parameter values are:
    // Config.Settings.RedisPoolSize = 10000
    // Config.Settings.RedisPoolTimeoutSeconds = 2
    // Config.Settings.RemoteCacheServerName = 192.168.10.12
    private static readonly PooledRedisClientManager instance
        = new PooledRedisClientManager(Config.Settings.RedisPoolSize,
                                       Config.Settings.RedisPoolTimeoutSeconds,
                                       new string[] { Config.Settings.RemoteCacheServerName })
        {
            ConnectTimeout = 1500
        };

    static RedisConnection()
    {
    }

    public static PooledRedisClientManager Instance
    {
        get
        {
            return instance;
        }
    }
}

用法如下:

public sealed class Caching
{
    public static T GetCacheSingle<T>(string key)
    {
    using (var redisClient = RedisConnection.Instance.GetReadOnlyClient())
    {
            var value = redisClient.Get<byte[]>(key);
            ....
    }
    }
}


推荐答案

这是由于Redis在Hyper-V上作为虚拟机托管的Ubuntu上运行而导致的延迟问题导致的。

This was caused by latency issue due to Redis running on Ubuntu hosted as a virtual machine on Hyper-V.

我们通过移至物理Linux机器上解决了问题,将延迟降低了45%。

We reduced latency by 45% by moving to a physical Linux box, fixing the problem.

这篇关于ServiceStack.Redis:无法连接:sPort:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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