Flooding MySQL Server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TheOnly92
Forum Newbie
Posts: 19
Joined: Thu Jan 15, 2009 6:05 am

Flooding MySQL Server

Post by TheOnly92 »

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?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Flooding MySQL Server

Post by Weirdan »

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).
TheOnly92
Forum Newbie
Posts: 19
Joined: Thu Jan 15, 2009 6:05 am

Re: Flooding MySQL Server

Post by TheOnly92 »

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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Flooding MySQL Server

Post by Weirdan »

Well, I'm using lighttpd so it shouldn't be a problem, but the problem is how PHP finds persistent connection?
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.
Post Reply