Forum Moderators: coopster
I run a high traffic website, one of the issues we have hit is we run out of available ports due to the way apache/php/mysql work together when apache and mysql are on diffrent servers.
It seems when apache closes the connection to mysql it sits in TIME_WAIT for quite some time. Now when a few 1000 people are on the site that eats up all the ports. Now as a temp fix I upped the amount of ports available for this. However it will obviously happen again. Once all the ports are gone the machine load spirals out of control and it locks up even at the console.
One thing that been suggested is to use pconnect, is this the best soloution or are others avaiable. We already have a load balencer and two servers, I don't want to just throw servers when theres cpu and ram resouces spare.
I'm sorry if this isn't quite the right section, as it covers LAMP in general I guess.
It's RHEL 4 with PHP 5, eaccelerator, stock apache and 64 bit stock mysql.
Thanks
They are found in HLKM\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters
They will not be found if they have not been treaked from their default, but they effect the time a connection will remain in WAIT from a TCP connection started as keepalive. You'll get good results if these values are set to something more sane like 30-60 (seconds).
HTTP KeepAlive and MySQL persistent connections are also bad on the public end and good internally because it's more likely that your internal hits (PHP--MySQL) will be reused more efficiently than public hits that you have little control over. If your public users run Windows, their connections will remain waiting too long as well, possibly consuming connections on your front-side HTTPd.
Most all OS's have a way to tweak this parameter, in some *NIX, it even has the same name.
ADD: one more thing if you're still interested :) -- I've seen the issue you describe with PHP scripts that make both external HTTP and MySQL connections under Apache -- sometimes it is necessary to lower the Apache directive MaxRequestsPerChild to cause the Apache children to shutdown more often to clear the connections -- on Windows, the single child never shuts down (MaxRequestsPerChild 0), so making this number nonzero (500, 1000, 5000) helps. Sometimes "KeepAlive On" in Apache will prevent the parent from restarting the children if there are connections in the WAIT state, so it's all related.