Flooding MySQL Server
Moderator: General Moderators
Flooding MySQL Server
I am using a script to get the status of some particular process every 1.5 seconds. The process may last to about 5 minutes long, which means in this period, 200 requests will be made. 200 requests means the script will be called 200 times. The script being called 200 times will create connection to the database server 200 times. Therefore actually flooding the MySQL server. I wonder if it is appropriate to use persistent connection in this situation because with the connections to MySQL server is closing very slowly (it usually stuck at TIME_WAIT, resulting in almost more than 500 TCP connections open in any given second). Or is there any solutions?
Re: Flooding MySQL Server
Persistent connections sounds like a good idea in this case, however they would work only if php process is not terminated completely (which is the case when it's running as apache module, however the process fully terminates if it's a simple command-line script).
Re: Flooding MySQL Server
Well, I'm using lighttpd so it shouldn't be a problem, but the problem is how PHP finds persistent connection? I have once tried to use persistent connection but it created more problems than I can solve.
Re: Flooding MySQL Server
It looks in the current process' connection pool for a connection having the same host + username + password combination. At least this is how it works with mysql extension.Well, I'm using lighttpd so it shouldn't be a problem, but the problem is how PHP finds persistent connection?