【.NET】asp.net core 程序重启容器后redis无法连接,连接超时

环境是容器化部署asp.net core 程序当有大量请求打到容器如果此时重启容器会出现,redis无法连接情况。

使用 csredis 库报错:

Status unavailable, waiting for recovery. Connect to server timeout

使用StackExchange.Redis 报错:

Timeout performing SET (5000ms), active: SET GtkPMF.MES:DistributedLock:GtkPMF.MES:MesSnLockKey:Test125, next: SET GtkPMF.MES:DistributedLock:GtkPMF.MES:MesSnLockKey:Test125 ** possible thread-theft indicated; see https://stackexchange.github.io/StackExchange.Redis/ThreadTheft ** , inst: 27, qu: 0, qs: 46, aw: False, rs: CompletePendingMessageSync, ws: Idle, in: 0, in-pipe: 311, out-pipe: 0, serverEndpoint: 10.10.28.207:7551, mc: 1/1/0, mgr: 9 of 10 available, clientName: svc-touchscreen-v1-6c589d57bb-vqbwl, IOCP: (Busy=0,Free=1000,Min=12,Max=1000), WORKER: (Busy=36,Free=32731,Min=12,Max=32767), v: 2.2.4.27433 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts

通过阅读文章

https://stackexchange.github.io/StackExchange.Redis/ThreadTheft

得知可能是由于初始线程过于少,无法应对大量的请求导致

尝试调整

在 Program.cs 修改如下:

复制代码
	 public static void Main(string[] args)
	 {
	     // 添加设置线程池最小线程数
	     ThreadPool.SetMinThreads(workerThreads: 100, completionPortThreads: 100);
	
	     CreateHostBuilder(args).Build().Run();
	 }

ok重写发布解决问题~

相关推荐
麦兜*9 分钟前
MongoDB 常见错误解决方案:从连接失败到主从同步问题
java·数据库·spring boot·redis·mongodb·容器
RestCloud23 分钟前
PostgreSQL大表同步优化:如何避免网络和内存瓶颈?
前端·数据库·api
阿里云大数据AI技术27 分钟前
淘宝闪购基于Flink&Paimon的Lakehouse生产实践:从实时数仓到湖仓一体化的演进之路
数据库·flink
努力学习的小廉40 分钟前
深入了解linux系统—— 线程同步
linux·服务器·数据库·算法
格调UI成品1 小时前
DCS+PLC协同优化:基于MQTT的分布式控制系统能效提升案例
数据库·云边协同
失散132 小时前
分布式专题——5 大厂Redis高并发缓存架构实战与性能优化
java·redis·分布式·缓存·架构
牵牛老人2 小时前
Qt C++ 复杂界面处理:巧用覆盖层突破复杂界面处理难题之一
数据库·c++·qt
GBASE2 小时前
GBASE南大通用技术分享:构建最优数据平台,GBase 8s数据库安装准备(三)
数据库
言之。2 小时前
Django REST Framework 中 @action 装饰器详解
数据库·sqlite
十八旬4 小时前
苍穹外卖项目实战(day7-1)-缓存菜品和缓存套餐功能-记录实战教程、问题的解决方法以及完整代码
java·数据库·spring boot·redis·缓存·spring cache