This article is a mirror article of machine translation, please click here to jump to the original article.

View: 32337|Reply: 3

[Source] MySQL performance optimization sets max_connections maximum number of connections

[Copy link]
Posted on 8/27/2021 10:02:14 AM | | | |
When the number of MySQL clients exceeds the maximum number of connections, drivers in different languages will report the error "Too many connections".

Java program error:

Data source rejected establishment of connection,  message from server: "Too many connections"


.NET Core program error:

Too many connections
Or so
error connecting: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached.


Use the following command to view the maximum number of connections and the current number of connections:



temporarily set the maximum number of connections,You don't need to restart the MySQL server, but the setting becomes invalid when you restart the MySQL service


You can permanently set the maximum number of connections to the database in /etc/my.cnf:


When we set the maximum number of connections and test with a .NET program, the error will still be as follows:

error connecting: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached.
This is due to the fact that .NET clients use thread pools by default, and the maximum limit for thread pools defaults to: 100

The hyperlink login is visible.

WeClose the pooling thread pool, without using the thread pool, there is no limit, the test is concurrent with 500 threads at the same time, and no error is reported, as shown in the figure below:



The .NET/C# test code looks like this:

(End)





Previous:nginx access issue connect() to 127.0.0.1:8080 failed (13: Permission den...
Next:Mechanical keyboard structure and schematic
 Landlord| Posted on 8/30/2021 1:16:26 PM |
Posted on 12/18/2021 8:32:19 PM |
The maximum number of connections per user

Posted on 5/19/2023 11:34:24 AM |
Learn to learn
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com