I run a rather busy site, and during peek hours I see over 10.000 open connections to my database server on my webserver when a run a netstat command. 99% of the connections are in the TIME_WAIT state.
I learned about this mysql variable: wait_timeout http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_wait_timeout today. Mine is still set at the default 28.800 seconds.
Is lowering this value safe?
Non of my queries usually takes over a second. So it seems silly to keep a connection open for 480 minutes.
I also heard about using mysql_pconnect instead of mysql_connect, but i've been reading nothing but horror stories about it, so I think i'll stay away from that.
wait_timeoutcause a connection to close when the software expects it to remain open. – John Gardeniers Feb 1 at 22:15