Relational Database Service (MySQL)

What should I do if an error message "connect established slowly" is reported on the client due to a slow connection on MySQL?

2024-06-24 09:42:17

Scenario Description

During peak hours, the connection between a client and MySQL often times out. As a result, it takes more than 10 seconds to log in to the system.

Possible Causes

View the MySQL error logs to see whether the information "connection xxx is established slowly" is displayed.

If yes, some connections have timed out and have not been processed by MySQL yet. When the connection between a client and the instance exceeds the specified timeout duration, an error is reported. The wait time for the thread pool to process connections is related to the parameter thread_pool_oversubscribe.

Solution

If there are a large number of new connections, increase the value of threadpool_oversubscribe to increase the total number of threads. Reduce the overheads of repeated thread creation and destruction to improve performance. This also limits the number of running threads on MySQL to protect the system against avalanche in critical moments.

In normal cases, the thread pool applies to scenarios with a large number of short connections. If persistent connections are used with a few connections (for example, the client uses a connection pool), the thread pool does not have a big impact.


Za9Zllwhjpap