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

Source: Internet
Author: User
Tags mysql command line

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 type of client (the Mysql_real_connect () The connection options client_interactive defined).
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 be connected to MySQL server after the corresponding operation is processed, You should disconnect and release the memory that is occupied. 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.

Issue:
    If only parameter wait_timeout=100 is set in the profile my.cnf, restart the server and enter, execute:
   Mysql> Show Variables like "%timeout%"; The
finds that the parameter setting is not in effect and remains 28800 (that is, the default of 8 hours).
After querying the data, 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 viewing settings have taken effect.

Question 1: Why do I have to set interactive_timeout,wait_timeout settings at the same time to take effect?

The value of the question 2:interactive if the setting is different from the wait_timeout, why does interactive_timeout overwrite wait_timeout?

Issue 3: In MySQL optimization, because interactive_timeout determines the length of time the interaction is connected, Wait_timeout determines the length of the non-interactive connection. 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 ?

Issue 4: In order to reduce the number of long connections, set the Is it possible to set the value of the interactive_timeout to a larger size while the Wait_timeout value is set smaller? But the description of question 2 doesn't seem to allow this ...

My settings: Go to MySQL command line

Set wait_timeout=180;
Set interactive_timeout=180;

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

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.