Configuration parameters in MySQL interactive_timeout and wait_timeout (two parameters that can cause excessive sleep processes)

Source: Internet
Author: User

1) Interactive_timeout:
Parameter meaning: The number of seconds that the server waits for activity before closing an interactive connection. The interactive client is defined as a client that uses the Client_interactive option in Mysql_real_connect ().
Parameter default value: 28,800 seconds (8 hours)

(2) Wait_timeout:
Parameter meaning: The number of seconds that the server waits for activity before closing a non-interactive connection.
When a thread starts, the session Wait_timeout value is initialized based on the global Wait_timeout value or global interactive_timeout value, depending on the client type (the connection option for the Mysql_real_connect () Client_ Interactive definition).
Parameter default value: 28,800 seconds (8 hours)

The maximum number of connections supported by the MySQL server is capped, because each connection is built to consume memory, so we want the client to disconnect and free up memory after connecting to MySQL server to process the appropriate operation. If your MySQL server has a large number of idle connections, they will not only consume memory in vain, but if the connection keeps accumulating, it will eventually reach the maximum number of MySQL server connections, which will report the error of ' too many connections '. For the value setting of wait_timeout, it should be judged according to the operation condition of the system. After the system has been running for a period of time, you can view the current system's connection status through the show Processlist command, if you find a large number of connection processes in the sleep state, then the parameter settings are too large to make the appropriate adjustment smaller.

Problem:
If only the parameter wait_timeout=100 is set in the config file my.cnf, after restarting the server, enter, execute:
Mysql> Show variables like "%timeout%";
You will see that the parameter setting is not in effect, still 28800 (that is, the default of 8 hours).
After you have queried the information, you must set both Interactive_timeout and wait_timeout to take effect.
"Mysqld"
wait_timeout=100
interactive_timeout=100
After restarting MySQL server entry, the view settings are in effect.


question 1: Why is this setting interactive_timeout,wait_ at the same time? Does the timeout setting take effect?



question 3: When it comes to MySQL optimization, because interactive_timeout determines the length of time for an interactive connection, wait_ Timeout determines the length of time that a non-interactive connection is made. If the Mysql_real_connect () last parameter client_flag is not set to client_interactive when making a connection configuration, the value of interactive_timeout is not overwritten wait_timeout ?

question 4: In order to reduce the number of long connections, it is not possible to set to optimize the interactive_ The value of timeout is set larger, and the value of wait_timeout is set smaller? But the description of question 2 doesn't seem to allow this ...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.