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

相关推荐
城北徐宫16 小时前
MySQL数据类型整理
数据库·mysql
数据库小学妹16 小时前
数据库容量规划:四个数与扩容触发线
运维·数据库·后端
时间的拾荒人16 小时前
Redis Cluster 集群详解:分片算法、搭建、故障处理与扩容实战
数据库·redis·算法·集群
纆兰19 小时前
MySQL的多表查询
数据库·mysql
七夜zippoe19 小时前
Nexent 模型配置:4 字段与 9 个槽位
数据库·人工智能·模型·nexent
进击的荆棘19 小时前
MySQL——表的操作
数据库·mysql
nice_lcj52021 小时前
MySQL 慢查询与 EXPLAIN:怎么定位、怎么优化
java·数据库·后端·mysql
Jeff-Tsai1 天前
Day 21:业务逻辑定制与 Plugin 的四个时点
.net·架构设计·erp·definition-driven
IT规划师1 天前
Redis 核心机制 | 键生命周期与 TTL 管理
redis·.net
OceanRoy1 天前
数据库表的设计
数据库·内连接·外连接·er图·表的约束·三大范式·多表连接