为什么 asp.net 上的 Azure Redis 缓存只使用 1000 个连接的少数客户端并抛出超时错误?
Why Azure Redis Cache on asp.net use only few connected client of 1000 and throw timeout error?
最近几天我正在尝试优化我的网站,因为当我有一个连接高峰时,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 and https://gist.github.com/JonCole/9225f783a40564c9879d#file-diagnoserediserrors-serverside-md?
如果您在 azurecache@microsoft.com 向我们发送以下信息 (https://gist.github.com/JonCole/132b255425268459ec95#file-supportquestionnaire-md),我们也可以进行调查,看看服务器上是否存在任何瓶颈以及我们可能有什么建议。
最近几天我正在尝试优化我的网站,因为当我有一个连接高峰时,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 and https://gist.github.com/JonCole/9225f783a40564c9879d#file-diagnoserediserrors-serverside-md?
如果您在 azurecache@microsoft.com 向我们发送以下信息 (https://gist.github.com/JonCole/132b255425268459ec95#file-supportquestionnaire-md),我们也可以进行调查,看看服务器上是否存在任何瓶颈以及我们可能有什么建议。