.NET CORE MySql MaxPoolSize不适用于 [英] .NET CORE MySql MaxPoolSize not applied in

查看:503
本文介绍了.NET CORE MySql MaxPoolSize不适用于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在RDS中托管了一个MySQl数据库.创建MySQL连接时,似乎未应用最大池大小. 我们有一个看起来像这样的连接字符串

We have a MySQl database hosted in RDS. When creating a MySQL Connection the maximum Pool size doesn't seem to be applied. We have a connection string that looks like this

Server=myServer;Port=3306;Database=MyDatabase;User Id=MyUser;Password=MyPassword;ConnectionReset=True;pooling=true;minpoolsize=1;maxpoolsize=4;ConnectionLifeTime=30"

我们在此处增加了最大池大小,但是我们的应用程序仍然保持过多的连接. 我已经在MySqlWorkbench中使用命令

We are adding the max pool size over here, but our application still keeps taking too many connections. I've verified this in MySqlWorkbench with the command

select * FROM INFORMATION_SCHEMA.PROCESSLIST

我们正在以正常方式创建sql连接..我在做什么错了?

We are creating a sql connection in a normal manner .. what am I doing wrong?

var connection = new MySql.Data.MySqlClient.MySqlConnection(_connectionString);
connection.Open()

技术信息: MySql Server版本:5.7.16

Technical Information: MySql Server Version: 5.7.16

MySqlConnector:(Nuget程序包)-> MySql.Data Version ="7.0.6-ir31"

MySqlConnector: (Nuget Package) -> MySql.Data Version="7.0.6-ir31"

更新:

在单元测试中执行此操作并并行打开MySQL连接时,一切似乎都正常.但是,当通过ASP.NET Core发出Web请求时,似乎出现了问题.

When executing this in a unit test and opening MySQL connections in parallel everything seems to go fine. However when web-requests come in via ASP.NET Core, there seems to be an issue.

推荐答案

我遇到了类似的情况.当使用运行.net core的负载平衡ec2实例时,最小和最大池大小似乎不起作用.就我而言,它正在击中Aurora mysql.

I've come across a similar situation. It appears that the min and max pool size doesnt work when using loadbalanced ec2 instances running .net core. In my case it is hitting aurora mysql.

问题似乎与在不同ec2实例上具有不同的最小和最大设置的不同连接字符串有关.似乎混淆了池中的最小值和最大值.

The problem seems to be associated with having different connection strings with different min and max settings on different ec2 instances. It seems to confuse the pool min and max.

解决方法(或修复)是确保所有ec2实例上的最小和最大池设置相同.击中数据库集群的那些人.

The work around ( or maybe fix ) is to make sure the min and max pool settings are the same on all the ec2 instances. that are hitting the db cluster.

这篇关于.NET CORE MySql MaxPoolSize不适用于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆