.NET CORE MySql MaxPoolSize not applied in

耗尽温柔 提交于 2019-12-22 00:45:06

问题


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

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.


回答1:


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.



来源:https://stackoverflow.com/questions/47682941/net-core-mysql-maxpoolsize-not-applied-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!