<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post//</link>
<title><![CDATA[MySQL Timeout解析]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Thu, 22 Apr 2010 07:03:19 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	“And God said, Let there be network: and there was timeout”<br/>在使用MySQL的过程中，你是否遇到了众多让人百思不得其解的Timeout？<br/>那么这些Timeout之后，到底是代码问题，还是不为人知的匠心独具？<br/>本期Out-man，讲述咱们MySQL DBA自己的Timeout。<br/><br/>先看一下比较常见的Timeout参数和相关解释：<br/><br/><div class="code">connect_timeout<br/>The number of seconds that the mysqld server waits for a connect packet before responding with Bad handshake.<br/>interactive_timeout<br/>The number of seconds the server waits for activity on an interactive connection before closing it.<br/>wait_timeout<br/>The number of seconds the server waits for activity on a noninteractive connection before closing it.<br/>net_read_timeout<br/>The number of seconds to wait for more data from a connection before aborting the read.<br/>net_write_timeout<br/>The number of seconds to wait for a block to be written to a connection before aborting the write.</div><br/><br/>从以上解释可以看出，connect_timeout在获取连接阶段（authenticate）起作用，interactive_timeout和wait_timeout在连接空闲阶段（sleep）起作用，而net_read_timeout和net_write_timeout则是在连接繁忙阶段（query）起作用。<br/><br/>获取MySQL连接是多次握手的结果，除了用户名和密码的匹配校验外，还有IP->HOST->DNS->IP验证，任何一步都可能因为网络问题导致线程阻塞。为了防止线程浪费在不必要的校验等待上，超过connect_timeout的连接请求将会被拒绝。<br/><br/>即使没有网络问题，也不能允许客户端一直占用连接。对于保持sleep状态超过了wait_timeout（或interactive_timeout，取决于CLIENT_INTERACTIVE标志）的客户端，MySQL会主动断开连接。<br/><br/>即使连接没有处于sleep状态，即客户端忙于计算或者存储数据，MySQL也选择了有条件的等待。在数据包的分发过程中，客户端可能来不及响应（发送、接收、或者处理数据包太慢）。为了保证连接不被浪费在无尽的等待中，MySQL也会选择有条件（net_read_timeout和net_write_timeout）地主动断开连接。<br/><br/>这么多Timeout足以证明MySQL是多么乐于断开连接。而乐于断开连接的背后，主要是为了防止服务端共享资源被某客户端（mysql、mysqldump、页面程序等）一直占用。<br/><br/><br/>作者：陶方 &#124; 【转载时请务必以超链接形式标明文章原始出处和作者信息及本声明】<br/>地址：http://rdc.taobao.com/blog/dba/html/433_mysql_timeout_analyze.html 
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] MySQL Timeout解析]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>