-
Notifications
You must be signed in to change notification settings - Fork 345
-
Hi all. I am working on a containerized .NET5.0 application and would like to understand what are some of the constraints and limitations that I may encountered when using MySqlConnector to access 1,000s of different databases simultaneously. These databases on hosted on multiple AWS RDS clusters.
What are the errors (exceptions) that I may encounter and potential strategies for managing these? That is,
- should the application back-off when it encounters those errors?
- can the application detect when it's close to these limits?
Are there any practical limits to the number of simultaneous connections to different databases that MySqlConnector will support comfortably?
I have looked through MySqlConnector documentation and this isn't clear. I have also looked on the internet and couldn't find a good answer to address the above questions.
Beta Was this translation helpful? Give feedback.
All reactions
1,000s of different databases simultaneously
You may benefit from disabling connection pooling (https://mysqlconnector.net/connection-options/#Pooling). By default, each unique connection string creates an implicit connection pool, which uses some amount of resources (memory, sockets). If you're connecting to 1,000s of servers, it may be best to avoid this overhead by adding Pooling = False;
to each connection string. (The only downside is that connection.Close(); connection.Open();
will close then recreate a TCP (or SSL) connection to each server instead of reusing a pooled connection. But overall it may be better this way.)
What are the errors (exceptions) that I may encounter and po...
Replies: 2 comments
-
1,000s of different databases simultaneously
You may benefit from disabling connection pooling (https://mysqlconnector.net/connection-options/#Pooling). By default, each unique connection string creates an implicit connection pool, which uses some amount of resources (memory, sockets). If you're connecting to 1,000s of servers, it may be best to avoid this overhead by adding Pooling = False;
to each connection string. (The only downside is that connection.Close(); connection.Open();
will close then recreate a TCP (or SSL) connection to each server instead of reusing a pooled connection. But overall it may be better this way.)
What are the errors (exceptions) that I may encounter and potential strategies for managing these?
In general, MySqlException
will be thrown for anything that goes wrong. MySqlErrorCode.UnableToConnectToHost
might be the most common error code you see. This can be retried with some kind of exponential backoff policy. I would recommend https://github.com/App-vNext/Polly#polly.
Are there any practical limits to the number of simultaneous connections to different databases that MySqlConnector will support comfortably?
None that I know of, beyond the limitations of your OS (e.g., maximum number of client sockets that can be open). Let me know if you find any!
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks for your quick response @bgrainge! I'll experiment and report back any interesting findings.
Beta Was this translation helpful? Give feedback.