当前位置: 首页 > news >正文

MySQL 的wait_timeout参数

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

下文描述了mysql的wait_timeout参数配置注意事项。简单的来讲要注意连接的程序用的是什么,是有状态的(如java,.net等)还是没状态的(如php,python等),有状态的wait_timeout连接时间要长(值范围60-259200),无状态的连接时间要短。mysql默认值是8小时。interactive_timeout(值范围10-86400)是用在shell交互时的超时时间。

其实很多性能优化的指导,都是如果无状态化。如缓存,静态化,轮循,分布式等,无状态很受欢迎。

 

Locate the timeout configuration and adjust it to fit your server.

wait_timeout = 28800
interactive_timeout = 28800
  • The interactive timeout does not affect any web application connections. A high interactive_timeout but a low wait_timeout is normal and is the best practice.

  • Choose a reasonable wait_timeout value. Stateless PHP environments do well with a 60 second timeout or less. Stateful applications that use a connection pool (Java, .NET, etc.) will need to adjust wait_timeout to match their connection pool settings. The default 8 hours (wait_timeout = 28800) works well with properly configured connection pools.

  • Configure the wait_timeout to be slightly longer than the application connection pool’s expected connection lifetime. This is a good safety check.

  • Consider changing the wait_timeout value online. This does not require a MySQL restart, and the wait_timeout can be adjusted in the running server without incurring downtime. You would issue set global wait_timeout=60 and any new sessions created would inherit this value. Be sure to preserve the setting in my.cnf. Any existing connections will need to hit the old value of wait_timeout if the application abandoned the connection. If you do have reporting jobs that will do longer local processing while in a transaction, you might consider having such jobs issue set session wait_timeout=3600 upon connecting.

转载于:https://my.oschina.net/swingcoder/blog/1518133

相关文章:

  • 快递鸟 即时查询接口
  • mySql基础
  • MySQL存储过程、触发器 小例子
  • Linux历史及版本
  • Java面试宝典《转载》
  • Android 03 style简单介绍
  • 黑客学习之信息收集
  • 安卓屏幕旋转时,禁止Activity重新加载
  • Selenium发展史
  • scala一些符号含义总结
  • Java内部类详解
  • tomcat配置、resin配置、MySQL主从配置
  • 代理
  • NetBIOS主机名扫描工具nbtscan
  • python开启进程的两种方法
  • github指令
  • JavaScript HTML DOM
  • Java程序员幽默爆笑锦集
  • mysql外键的使用
  • Python_OOP
  • webpack+react项目初体验——记录我的webpack环境配置
  • Yeoman_Bower_Grunt
  • 初识MongoDB分片
  • 记一次删除Git记录中的大文件的过程
  • 聊聊sentinel的DegradeSlot
  • 让你的分享飞起来——极光推出社会化分享组件
  • 用Python写一份独特的元宵节祝福
  • 国内唯一,阿里云入选全球区块链云服务报告,领先AWS、Google ...
  • ​Distil-Whisper:比Whisper快6倍,体积小50%的语音识别模型
  • ​LeetCode解法汇总2304. 网格中的最小路径代价
  • ​草莓熊python turtle绘图代码(玫瑰花版)附源代码
  • ​软考-高级-信息系统项目管理师教程 第四版【第23章-组织通用管理-思维导图】​
  • $jQuery 重写Alert样式方法
  • %check_box% in rails :coditions={:has_many , :through}
  • (javascript)再说document.body.scrollTop的使用问题
  • (八)Spring源码解析:Spring MVC
  • (附源码)springboot 个人网页的网站 毕业设计031623
  • (附源码)springboot 智能停车场系统 毕业设计065415
  • (转)ABI是什么
  • (转)LINQ之路
  • *Django中的Ajax 纯js的书写样式1
  • .gitignore文件_Git:.gitignore
  • .NET 中 GetHashCode 的哈希值有多大概率会相同(哈希碰撞)
  • .NET(C#) Internals: as a developer, .net framework in my eyes
  • .net下简单快捷的数值高低位切换
  • .net中应用SQL缓存(实例使用)
  • /proc/vmstat 详解
  • [ vulhub漏洞复现篇 ] Django SQL注入漏洞复现 CVE-2021-35042
  • []指针
  • [2015][note]基于薄向列液晶层的可调谐THz fishnet超材料快速开关——
  • [CISCN 2023 初赛]go_session
  • [CSS]CSS 的背景
  • [CSS]盒子模型
  • [EFI]Acer Aspire A515-54g电脑 Hackintosh 黑苹果efi引导文件
  • [ERROR] ocp-server-ce-py_script_start_check-4.2.1 RuntimeError: ‘tenant_name‘