I run a free invisible counter service (http://angrybeancounter.com/
). But, I have a problem.
The script is powered by a MySQL database. The main counter script is called every time someone visits a site with the counter on, and since this happens a lot, many MySQL connections can be opened at once, which have led to the script using a lot of CPU power, and my host temporarily suspending my account.
At the moment, it is set to check the server load before connecting to the MySQL server, and if it is above a certain level, then it will just die. This is so it won't eat up all available CPU power. This unfortunately also means that many hits get 'lost'.
The evil script is here
. Is there anything anyone can think of that would make it go faster (especially as far as MySQL connections are concerned)?
I thought about writing all the hits to a data file then updating the main database via a cron'd script every so often, but that means I can't access the user's settings.
Thanks for any help.