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.
解决方案
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.