Tod*_*ier 9 connection-pooling redis servicestack
I work on a few .NET web apps that use Redis heavily for caching along with ServiceStack's Redis client. In all cases I've got Redis running on the same machine. I've used both BasicRedisClientManager and PooledRedisClientManager (always implemented as singletons) and have had some issues with both approaches.
With BasicRedisClientManager, things would work fine for a while, but eventually Redis would start refusing connections. Using netstat we discovered that thousands of TCP connections to the default Redis port were hanging around in TIME_WAIT status.
We then switched to PooledRedisClientManager, which seemed to fix the problem immediately. However, not long after, we started noticing occasional CPU spikes that we narrowed down to thread waiting (System.Threading.Monitor.Wait calls) caused by PooledRedisClientManager.GetClient.
In code, we use a get-in-get-out approach (using ServiceStack's handy ExecAs shortcuts) so in general connections are acquired very frequently but held as briefly as possible.
We get a modest amount of traffic but we're no StackExchange, and I can't help but think the ServiceStack client is up to the job and we're just doing something wrong. Is PooledRedisClientManager the correct approach here? Would it be advisable to simply increase the pool size? Or is that likely just masking a problem with our code?
只是在这里寻找一般指导,我没有特定的代码,我现在需要帮助.提前致谢.
你绝对确定所有Redis连接都被处理掉了吗?
使用ServiceStack时,Redis属性Service和ViewPageBase(如果您使用的是SS Razor)会自行处理,但是当您自己请求从池中连接时,您必须自己处理它.
然而,尽管如此,我们最近还遇到了一个问题,即我们的游泳池也已经耗尽了所有连接.我的一位同事发现没有对Razor页面进行适当的清理并在此处发出拉取请求- 这意味着自ServiceStack v4.0.21以来,Razor页面上只有正确的处理方式.我没有检查该修复程序是否已经反向移植到v3分支.
我的同事还补充说TrackingRedisClientsManager,可以帮助您追踪不当处置.看到这里
您还可以PooledRedisClientManager 使用此帮助程序方法检查a的统计信息.我们把它扔在一个小剃刀页面上,以检查我们认为合适的统计数据)但你可以编写更好的代码来监控特定节点的池健康状况.
| 归档时间: |
|
| 查看次数: |
3150 次 |
| 最近记录: |