c mysql maxpoolsize_.NET CORE MySql MaxPoolSize不适用

bd96500e110b49cbb3cd949968f18be7.png

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"

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

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()

3HXNA.jpg

Technical Information:

MySql Server Version: 5.7.16

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

UPDATE:

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.

解决方案

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.

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.

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值