MySQL 的wait_timeout参数
MySQL 的wait_timeout参数
swingcoder 发表于8个月前
MySQL 的wait_timeout参数
  • 发表于 8个月前
  • 阅读 8
  • 收藏 0
  • 点赞 0
  • 评论 0





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.

  • 打赏
  • 点赞
  • 收藏
  • 分享
共有 人打赏支持
粉丝 28
博文 259
码字总数 57965
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
* 支付类型