Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of Timeout in MySQL

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Today, I will talk to you about the role of Timeout in MySQL. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

Connect_timeout 、 interactive_timeout 、 wait_timeout 、 net_read_timeout 、 net_write_timeout 、

[@ more@]

"And God said, Let there be network: and there was timeout"

In the process of using MySQL, have you encountered a lot of puzzling Timeout?

So after all these Timeout, is it the code problem or the unknown ingenuity?

In this issue of Out-man, we talk about MySQL DBA's own Timeout.

First, take a look at the more common Timeout parameters and related explanations:

Connect_timeout

The number of seconds that the mysqld server waits for a connect packet before responding with Bad handshake.

Interactive_timeout

The number of seconds the server waits for activity on an interactive connection before closing it.

Wait_timeout

The number of seconds the server waits for activity on a noninteractive connection before closing it.

Net_read_timeout

The number of seconds to wait for more data from a connection before aborting the read.

Net_write_timeout

The number of seconds to wait for a block to be written to a connection before aborting the write.

As can be seen from the above explanation, connect_timeout plays a role in the connection acquisition phase (authenticate), interactive_timeout and wait_timeout play a role in the connection idle phase (sleep), and net_read_timeout and net_write_timeout play a role in the connection busy phase (query).

Obtaining a MySQL connection is the result of multiple handshakes. In addition to the matching check of username and password, there is also IP- > HOST- > DNS- > IP verification. Any step may cause thread blocking due to network problems. To prevent threads from wasting on unnecessary parity waits, connection requests that exceed the connect_timeout will be rejected.

Even if there are no network problems, the client cannot be allowed to occupy the connection all the time. For clients that keep the sleep state beyond the wait_timeout (or interactive_timeout, depending on the CLIENT_INTERACTIVE flag), MySQL actively disconnects.

Even if the connection is not in the sleep state, that is, the client is busy calculating or storing data, MySQL chooses to wait conditionally. During the distribution of a packet, the client may not have time to respond (sending, receiving, or processing the packet is too slow). In order to ensure that the connection is not wasted in endless waiting, MySQL will also choose to actively disconnect conditionally (net_read_timeout and net_write_timeout).

So many Timeout is enough to prove how happy MySQL is to disconnect. The main reason behind the willingness to disconnect is to prevent the shared resources of the server from being occupied by a client (mysql, mysqldump, page program, etc.).

After reading the above, do you have any further understanding of the role of Timeout in MySQL? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report