is there some sort of software or whatever that can detect where errors are, and what can cause problems ie crashes. which = server load and slow responce on webpage?
Bug testing and error finding
Collapse
X
-
n00bs should not apply in your own words ???
anyway this is not a special software based solution
1. Learn to optimise, queries in loops are forbidden, never do it, what i do is use a mysql query function on large sites to view queries, something like
Code:function sql_query($query) { global $queries, $query_stat; if(!isset($queries)) $queries = 0; if(!isset($query_stat)) $query_stat = array(); $queries++; $mtime = microtime(); // Get Current Time $mtime = explode (" ", $mtime); // Split Seconds and Microseconds $mtime = $mtime[1] + $mtime[0]; // Create a single value for start time $query_start_time = $mtime; // Start time $result = mysql_query($query); // do not change to sql_query $mtime = microtime(); $mtime = explode (" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $query_end_time = $mtime; // End time $query_time = ($query_end_time - $query_start_time); $query_time = substr($query_time, 0, 8); $query_stat[] = array("seconds" => $query_time, "query" => $query); return $result; }
Code:if($userid == 1) { foreach($query_stat as $key => $value) print("[".($key+1)."] => <b>".($value["seconds"] > 0.01 ? "<font color=\"red\" title=\"I suggest you should optimize this query.\">".$value["seconds"]."</font>" : "<font color=\"green\" title=\"This query doesn't need's optimization.\">".$value["seconds"]."</font>" )."</b> [$value[query]]<br />\n"); }
2. enable slow query logging in my.cnf (mysqls config file). This will log any queries that take longer than x seconds (x is defined in my.cnf) to execute. Pretty much like above but more accurate and it never hurts to have extra logging
3. in php.ini or at the start of one of your main include files like core.php add
Code:error_reporting(E_ALL); ini_set("display_errors",1);
4. if you have shell access you can use the top command to give you an idea of if its a mysql or apache issue (you can also tell if its a php issue if php is running in cgi, you run php as a apache module then php is part of the apache process so there not seperately shown). Soo you could either just typeCode:top
Code:top -u www-data
thats more than enough to get you going, there is a hell of a lot more you could do but the above are usually enough to satisfy most people.
Comment
Comment