Question:
PHP based log overloading MySQL server?
Bud Smith
2008-02-27 14:05:45 UTC
I am having problems with my database occasionally saying "Too many connections". I have designed my script to be quite easy on the database, it will cache results when ever possible and close all database connections.

My problem is that I want to log details of each request and get these details into a MySQL database. It seems as if the logging directly to MySQL is causing it to overload.

I can not use the Apache Log files instead as some of the data I wish to log is only available when PHP is running.

Does anyone have any ideas on how I can write the logging script so that it does not need to connect to the database for every request?
Three answers:
anonymous
2008-03-06 10:08:39 UTC
Run the query "SHOW PROCESSLIST " to see how many processes are running. Maybe you have a bunch of sleeping processes that need to be killed that are hogging your limited connections. This often happens when a PHP script doesn't properly finish because of a Fatal error and the connection that you opened in your script doesn't send a command to mysql to close it.



If you have any sleeping processes, kill them simply with the SQL command 'KILL ID NUMBER' where ID NUMBER is the number of the sleeping process.



If thats not the issue, maybe you need to increase the amount of concurrent connections your MySQL database allows (if you have access to do this).
rohlman
2016-10-23 01:12:01 UTC
regularly, and that i dont truly recognize your setup, yet think ofyou've got a connection string on your Hypertext Preprocessor web page that ought to hook up with the database. it would nicely be a miles off database (not on an same server) and which will be high-quality. Connection strings regularly contain a username, password and IP deal with/Port for the MySQL database. in the journey that your attempt Hypertext Preprocessor web page is returning documents out of your database, i ought to assert your high-quality. or you should desire to study connection strings in Hypertext Preprocessor.
Daniel B
2008-02-28 15:06:18 UTC
Why don't you just place a text file (.txt) file on your sever somewhere, fopen() the file in PHP and Write whatever you want to it, and close it, and then just keep appending to the file? Need more help? beachdan84@gmail.com , but that should work.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...