在过去的几天里,我正在尝试优化我的网站,因为当我有连接高峰时,redis 缓存导致性能低下。
我使用的是redis版本1.2.6,并且我在连接字符串中设置了abortConnect=false。
这是我如何获得与 Redis 的连接:
private static readonly Lazy<ConnectionMultiplexer> LazyConnection
= new Lazy<ConnectionMultiplexer>(() =>
ConnectionMultiplexer.Connect(GetRedisConnectionString()));
private static readonly Lazy<ConnectionMultiplexer> LazyConnection
= new Lazy<ConnectionMultiplexer>(() =>
{
var connection = ConnectionMultiplexer.Connect(GetRedisConnectionString());
connection.PreserveAsyncOrder = false;
//connection.TimeoutMilliseconds
return connection;
});
在 global.asax 中,我按照本文的建议更改了最小线程 http://stackexchange.github.io/StackExchange.Redis/Timeouts
int workerThreads = 500;
int iocpThreads = 500;
System.Threading.ThreadPool.SetMinThreads(workerThreads, iocpThreads)
但是我们在日志中仍然有一些像这样的错误:
Timeout performing GET campaign_url_728566_288, inst: 19, mgr: Inactive,
err: never, queue: 7, qu: 0, qs: 7, qc: 0, wr: 0, wq: 0, in: 0, ar: 0,
clientName: RD00155D881345, serverEndpoint:
Unspecified/**********************, keyHashSlot: 6859, IOCP:
(Busy=0,Free=1000,Min=500,Max=1000), WORKER:
(Busy=25,Free=8166,Min=500,Max=8191)
或
Timeout performing GET campaign_url_728566_288, inst: 7, mgr: Inactive, err:
never, queue: 24, qu: 0, qs: 24, qc: 0, wr: 0, wq: 0, in: 4488, ar: 0,
clientName: RD00155D881345, serverEndpoint: Unspecified**********,
keyHashSlot: 6859, IOCP: (Busy=0,Free=1000,Min=500,Max=1000), WORKER:
(Busy=40,Free=8151,Min=500,Max=8191)
现在我注意到创建并在门户中显示的最大连接数为最大 20,而我预计在高流量期间会拥有更多连接。
是否有任何设置可以增加 ConnectionMultiplexer 的连接数?或者问题与缓存的大小(当前为 C1 标准)或由于带宽有限有关?
最佳答案
此类问题可能是由服务器或客户端问题引起的。您查看过https://gist.github.com/JonCole/db0e90bedeb3fc4823c2#file-diagnoserediserrors-clientside-md吗?和 https://gist.github.com/JonCole/9225f783a40564c9879d#file-diagnoserediserrors-serverside-md ?
如果您通过 https://gist.github.com/JonCole/132b255425268459ec95#file-supportquestionnaire-md 向我们发送以下信息 ( [email protected] ) ,我们也可以调查一下服务器上是否存在任何瓶颈以及我们可能有什么建议。
关于asp.net - 为什么 asp.net 上的 Azure Redis 缓存仅使用 1000 个连接的客户端并抛出超时错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48149329/