Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MySqlConnector: Constraints and limitations #1073

Answered by bgrainger
colin-sim asked this question in Q&A
Discussion options

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.

You must be logged in to vote

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

Comment options

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!

You must be logged in to vote
0 replies
Answer selected by colin-sim
Comment options

Thanks for your quick response @bgrainge! I'll experiment and report back any interesting findings.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /