purrp
Programmer
- Nov 22, 2007
- 1
Hi all,
I've set up a few simple php scripts to update some server statistics. I call them regularly using cron and wget. I'm using Apache 2.2.6 on CentOS.
I've noticed that SOMETIMES, the connections to these scripts don't get closed. In WebHost Manager, I see the MySQL processes remain as "Sleep", and the Apache connections are left as "Sending Reply". The connections stay like this until the MySQL connection expires (after 24 hours, I believe).
This doesn't seem to happen with any of the php scripts of the site itself (about 80,000 page views per day), even though there's no difference in how I set up the database connection, etc. The statistics scripts that are giving me problems simply call one or two queries, which take at most a couple of seconds to complete (worst case 5-6 seconds). The only difference that I can think of is they're called using wget.
Annoyingly, a connection doesn't get left open EVERY time the cron job runs, which makes it harder to troubleshoot.
I close the database connection at the end of every script. I've also added the no-http-keep-alive flag to wget. Doesn't seem to help.
Does anyone have any hints how I could find more information about what's causing the problem? This kind of thing is never easy to isolate...
I'm not even sure if it's a problem with Apache, with PHP, or with MySQL, but maybe some of the Apache gurus here have run into something similar before?
Thanks for any help,
Alex
I've set up a few simple php scripts to update some server statistics. I call them regularly using cron and wget. I'm using Apache 2.2.6 on CentOS.
I've noticed that SOMETIMES, the connections to these scripts don't get closed. In WebHost Manager, I see the MySQL processes remain as "Sleep", and the Apache connections are left as "Sending Reply". The connections stay like this until the MySQL connection expires (after 24 hours, I believe).
This doesn't seem to happen with any of the php scripts of the site itself (about 80,000 page views per day), even though there's no difference in how I set up the database connection, etc. The statistics scripts that are giving me problems simply call one or two queries, which take at most a couple of seconds to complete (worst case 5-6 seconds). The only difference that I can think of is they're called using wget.
Annoyingly, a connection doesn't get left open EVERY time the cron job runs, which makes it harder to troubleshoot.
I close the database connection at the end of every script. I've also added the no-http-keep-alive flag to wget. Doesn't seem to help.
Does anyone have any hints how I could find more information about what's causing the problem? This kind of thing is never easy to isolate...
I'm not even sure if it's a problem with Apache, with PHP, or with MySQL, but maybe some of the Apache gurus here have run into something similar before?
Thanks for any help,
Alex