MySQL wait_timeout and WordPress

I’m troubleshooting a series of reoccurring errors: WordPress database error MySQL server has gone away for query ...

I think I’ve found a solution here but it’s a few years old and I want to better understand the MySQL wait_timeout and it’s relationship to WordPress before I start monkeying with core files or reconfiguring my server. (I’m on a virtual dedicated server, so I have the option to change the wait_timeout on the server.)

Read More

I checked by running SHOW VARIABLES; from phpMyAdmin and wait_timeout is currently set to 35. That seems low to me, but I don’t fully understand what it does. I’m considering changing it to 600.

My main question is whether this is a responsible thing to do or not. But I think that broader question can be divided into smaller parts:
1. Do I have the option to override this setting with PHP (WordPress)?
2. What is the optimal setting is for medium-large WordPress site?
3. Are there any WordPress configuration options or filters that I could use to change the setting without modifying core files?

Thanks.

Related posts

Leave a Reply

1 comment

  1. wait_timeout is the time mysql will hold a non-interactive connection open for before closing it basically.

    So increasing it to 600 seconds could solve your problem, however, if you set it to 600 seconds and you have lots of people running a slow page on your site at the same time you can get to a point where mysql starts refusing connections and then apache will start queueing requests until it subsequently refuses requests and your server takes a dive.

    My suggestion would be to try and find out why a single request is taking over 35 seconds because to be honest, that seems a rather long load time on a single page from a blog to me.