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

相关推荐
夜泉_ly1 小时前
MySQL -安装与初识
数据库·mysql
qq_529835352 小时前
对计算机中缓存的理解和使用Redis作为缓存
数据库·redis·缓存
月光水岸New5 小时前
Ubuntu 中建的mysql数据库使用Navicat for MySQL连接不上
数据库·mysql·ubuntu
狄加山6755 小时前
数据库基础1
数据库
我爱松子鱼5 小时前
mysql之规则优化器RBO
数据库·mysql
chengooooooo5 小时前
苍穹外卖day8 地址上传 用户下单 订单支付
java·服务器·数据库
Rverdoser6 小时前
【SQL】多表查询案例
数据库·sql
Galeoto6 小时前
how to export a table in sqlite, and import into another
数据库·sqlite
人间打气筒(Ada)7 小时前
MySQL主从架构
服务器·数据库·mysql
leegong231117 小时前
学习PostgreSQL专家认证
数据库·学习·postgresql