MySQL : interactive_timeout v/s wait_timeout
Most of the database intensive applications are worring about the default values of these variables obviously. Developers used to inform me that they need to extend the wait_timeout value in order to complete the query execution.
After some googling, it is found that default “wait_timeout” value is good enough. We may need to reduce it to boost the server performance which will helpful to minimize the “sleep” process loaded in memory. Increasing number of sleeping process will reduces the server performance gradually. So always keep the default value and make it reduce until the program/application does not create any sleeping process which would helpful to improve the performance noticeable. Slow_log_query is another possible reason to have many sleeping process.
interactive_timeout : interactive time out for mysql shell sessions in seconds like mysqldump or mysql command line tools.
wait_timeout” : the amount of seconds during inactivity that MySQL will wait before it will close a connection on a non-interactive connection in seconds.
How to change the these variables
a. changing values at run time
Log in to the mysql console and set the variable.
mysql> SET interactive_timeout=200;
Query OK, 0 rows affected (0.01 sec) mysql> SET GLOBAL interactive_timeout=200;
Query OK, 0 rows affected (0.00 sec) mysql> show variables like "%timeout%";
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| connect_timeout | 200 |
| delayed_insert_timeout | 300 |
| innodb_lock_wait_timeout | 50 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 200 |
| net_read_timeout | 200 |
| net_write_timeout | 200 |
| slave_net_timeout | 3600 |
| table_lock_wait_timeout | 50 |
| wait_timeout | 200 |
+----------------------------+-------+
10 rows in set (0.00 sec)
b. Using my.cnf : Add the following values in /etc/my.cnf” and restart the mysql server.
[mysqld]
interactive_timeout=180
wait_timeout=180
Pls note that “wait_timeout” would be helpful to clear the sleeping process as “interactive_timeout” does not make any performance improvement since it affect the command line sessions. Obviously increasing the values of connect_timeout, net_read_timeout andnet_write_timeout would help to skip the timeout errors when lengthy queries are being executed.
How to kill the MySQL Sleeping process
mysql> show full processlist;
+-------+------------+---------------------+---------------+---------+------+-------+-----------------------+
| Id | User | Host | db | Command | Time | State | Info |
+-------+------------+---------------------+---------------+---------+------+-------+-----------------------+
| 9435 | user | 192.168.10.15:52180 | db1 | Sleep | 26 | | NULL |
| 9943 | user | localhost:51179 | db2 | Sleep | 1 | | NULL |
| 9944 | user | localhost:54007 | db2 | Sleep | 29 | | NULL |
| 9947 | user | localhost:60638 | db2 | Sleep | 29 | | NULL |
| 10716 | root | localhost | NULL | Sleep | 5432 | | NULL |
| 10851 | root | localhost | NULL | Query | 0 | NULL | show full processlist |
+-------+------------+---------------------+---------------+---------+------+-------+-----------------------+
6 rows in set (0.00 sec) mysql> kill 9944;
Query OK, 0 rows affected (0.00 sec) mysql> show full processlist;
+-------+------------+---------------------+---------------+---------+------+-------+-----------------------+
| Id | User | Host | db | Command | Time | State | Info |
+-------+------------+---------------------+---------------+---------+------+-------+-----------------------+
| 9435 | user | 192.168.10.15:52180 | db1 | Sleep | 7 | | NULL |
| 9943 | user | localhost:51179 | db2 | Sleep | 9 | | NULL |
| 9947 | user | localhost:60638 | db2 | Sleep | 10 | | NULL |
| 10716 | root | localhost | NULL | Sleep | 5473 | | NULL |
| 10851 | root | localhost | NULL | Query | 0 | NULL | show full processlist |
| +-------+------------+---------------------+---------------+---------+------+-------+-----------------------+
7 rows in set (0.01 sec)
mysql>
On thread startup, the session wait_timeout value is initialized from the global wait_timeout value or from the global interactive_timeout value, depending on the type of client (as defined by the CLIENT_INTERACTIVEconnect option to mysql_real_connect()).
参考:
http://www.serveridol.com/2012/04/13/mysql-interactive_timeout-vs-wait_timeout/
http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_wait_timeout
MySQL : interactive_timeout v/s wait_timeout的更多相关文章
- Ubuntu下mysql修改连接超时wait_timeout
命令行登入mysql show variables like '%timeout%':(其中有用的是: interactive_timeout 和wait_timeout 为28800,默认为8小 ...
- Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionExcep linux下mysql修改连接超时wait_timeout修改后就ok了
Linux下mysql修改连接超时wait_timeout 1,首先: show variables like '%timeout%': 显示结果: +------------------------ ...
- MySQL配置参数:wait_timeout
作者:老王 如果你没有修改过MySQL的配置,缺省情况下,wait_timeout 的初始值是. wait_timeout过大有弊端,其体现就是MySQL里大量的SLEEP进程无法及时释放,拖累系统性 ...
- MySQL查看和修改wait_timeout
1.全局查看wait_timeout值 mysql> show global variables like 'wait_timeout'; 2.修改全局wait_timeout值 set glo ...
- MySQL中的配置参数interactive_timeout和wait_timeout(可能导致过多sleep进程的两个参数)
1)interactive_timeout:参数含义:服务器关闭交互式连接前等待活动的秒数.交互式客户端定义为在mysql_real_connect()中使用CLIENT_INTERACTIVE选项的 ...
- 设置mysql的interactive_timeout和wait_timeout的值
1,为什么要重新设置这两个变量的值? 因为如果数据库默认这两个变量的值是8小时(即28800秒)如果在8小时之内没有连接到数据库,等下次再连的时候就会抛连接超时,或连接关闭这样的异 常,但是多连接几次 ...
- mysql wait_timeout和interactive_timeout总结
(1)interactive_timeout:参数含义:服务器关闭交互式连接前等待活动的秒数.交互式客户端定义为在mysql_real_connect()中使用CLIENT_INTERACTIVE ...
- MySQL:参数wait_timeout和interactive_timeout以及空闲超时的实现【转】
一.参数意思 这里简单解释一下两个参数,含义如下: interactive_timeout:The number of seconds the server waits for activity on ...
- interactive_timeout和wait_timeout(
mysql> show variables like "%timeout%"; +-----------------------------+----------+ | Va ...
随机推荐
- Python学习路程day7
多态 class Animal: def __init__(self, name): # Constructor of the class self.name = name def talk(self ...
- 数据结构《14》----并查集 Union-Find
描述: 并查集是一种描述解决等价关系.能够方便地描述不相交的多个集合. 支持如下操作 1. 建立包含元素 x 的集合 MakeSet(x) 2. 查找给定元素所在的集合 Find(x), 返回 ...
- 转发:在开发机上绕过Chrome同源策略的办法
在开发机上绕过Chrome同源策略的办法 标签: Chrome同源策略跨域 2013-08-21 18:33 4399人阅读 评论(0) 收藏 举报 分类: Chrome扩展(1) 版权声明:本文为博 ...
- 对前端mvc的认识和思考
现在,我们经常都可以看到复杂的JavaScript应用程序,由于这些应用程序变得越来越复杂,一长串的jQuery回调语句或者通过应用程序在 各个状态执行不同的函数调用,这些做法都会变得无法再让人接受, ...
- Net use命令
以指定账户密码建立网络磁盘 net use s: \\ip\ipc$ "密码" /user:“用户名”
- JSOI地铁换票 (贪心)
简单贪心即可. ..] of longint; var a,b:arr; i,n,m,sum:longint; procedure sort(var a:arr;l,r: longint); var ...
- 中文圣经 for Android
中文圣经(For Android) 目前,中文圣经App包含了如下圣经版本: 和合本 现代中文译本 吕振中译本 中文新译本 英文标准本(ESV) King James Version(KJV) New ...
- Java 中空指针处理方法
空指针异常(Null Pointer Exception)是我们平时最容易碰到的,也是最令人讨厌的异常.本文介绍如何避免出现空指针异常. 首先我们看如下的示例: private Boolean isF ...
- c语言 如何判断是不是 可显字符
c语言 如何判断是不是 可显字符int isprint(int c)若可显示返回1,否则0:要包含头文件ctype.h
- 听VOA还不如学这些 (转自知乎恶魔奶爸)
该专栏文章网址 http://zhuanlan.zhihu.com/aisapo/19634180 鉴于知乎无法插图片和音频,所以有了这篇教程集合,大家看这个就足够了其实 每次一学英语,材料无非就是V ...