Description
Hello,
I've run into connection pooling issue when authenticating to MySQL using IAM authentication.
When using IAM authentication, my service created a new authentication token for each database connection, which becomes part of the connection string as the password. These tokens contain a timestamp with a precision of seconds. This basically results in a unique connection string for every second.
During a load-test, I've quickly hit the maximum number of connections on my Aurora instance. I've been tuning the maxpoolsize
parameter, but to no avail - Only then I realised that connection pools are defined through connection strings and since they were changing every second, I've had plenty of connection pools with only a few connections pooled.
As a work-around I'm now caching the authentication token - they're valid for 15 minutes. This works but isn't ideal - After 15 minutes, the first connection pool gets drained while a new connection pool gets populated. Effectively this means that I can only use half of the available maximum connection per instance as maxpoolsize
.
I was thus wondering if there's a better way to handle this? Looking into the code one way of doing this would be to exclude the password from the normalizedConnectionString
around here https://github.com/mysql-net/MySqlConnector/blob/master/src/MySqlConnector/Core/ConnectionPool.cs#L394 - But I'm not sure about the implications. Potentially this might be configurable?
Looking forward to having your thoughts on this!
Thanks a lot for the great library by the way.
Daniel