【.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重写发布解决问题~

相关推荐
sc.溯琛11 分钟前
MySQL 入门实验:环境搭建与基础操作全攻略
数据库·mysql
JIngJaneIL17 分钟前
基于java+ vue建筑材料管理系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot
一 乐19 分钟前
办公系统|基于springboot + vueOA办公管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端·spring
麦麦鸡腿堡26 分钟前
MySQL表的操作指令与常用数值类型
数据库·mysql
煎蛋学姐31 分钟前
SSM小学教师教辅管理平台526h9(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库
java1234_小锋1 小时前
说说Redis的内存淘汰策略?
数据库·redis·缓存
她说..1 小时前
Spring AOP场景4——事务管理(源码分析)
java·数据库·spring boot·后端·sql·spring·springboot
道剑剑非道1 小时前
Qt【使用libmodbus库】
开发语言·数据库·qt
男孩李1 小时前
linux下执行pg数据的sql文件,报错error:permission denied for schema plat
数据库·sql