Jump to content

Troubleshooting intermittent http 500 errors


pgz81

Recommended Posts

Hi all,

 

I am creating my first store in Prestashop 1.6.1.6 in a shared hosting server on Apache/Linux. I am doing some SEO and performance tests using Screaming Frog (a web spider tool for SEO purposes) and JMeter (a web performance tool).

 

I have noticed using these tools that my shop is throwing HTTP 500 errors and some HTTP 503 errors. Around 30% of requests get an HTTP 500 error which is not acceptable. Affected URLs vary from test to test. If I try to hit those URLs from my browser, they display correctly. It seems to be related to request arrival rate.

 

I have simulated access to the homepage and one category page and one cms content page using Jmeter. If the test simulates just one user accessing the pages, all requests get an HTTP 200 status code. However, when I run the same tests for 2 users, HTTP errors start to appear. I think that aiming for two concurrent users should not be a challenge even for a small server.

 

I would like to get some advice about how to further troubleshoot this issue given the intermittent nature of the problem. My shared hosting provider does not allow me access to Apache error_log file or PHP error log files. They have provided me the following piece of PHP code:

 

error_reporting(0); 
     $old_error_handler = set_error_handler("userErrorHandler"); 
 
     function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars) 
     { 
       $time=date("d M Y H:i:s");
       // Get the error type from the error number 
       $errortype = array (1 => "Error", 
                           2 => "Warning", 
                           4 => "Parsing Error", 
                           8 => "Notice", 
                           16 => "Core Error", 
                           32 => "Core Warning", 
                           64 => "Compile Error", 
                           128 => "Compile Warning", 
                           256 => "User Error", 
                           512 => "User Warning", 
                           1024 => "User Notice"); 
       $errlevel=$errortype[$errno]; 
 
       //Write error to log file (CSV format) 
       $errfile=fopen("errors.csv","a"); 
       fputs($errfile,""$time","$filename: 
       $linenum","($errlevel) $errmsg"rn");
       fclose($errfile); 
 
       if($errno!=2 && $errno!=8) {
          //Terminate script if fatal error 
          die("A fatal error has occurred. Script execution has been aborted"); 
       } 
     }
 
They say I should include this piece of code in any php page I would like to troubleshoot. However, I do not know how to do this for Prestashop. Should I create a error.php file and include the file in the header.tpl file from my template?
 
Any hints would be appreciated.
Thanks in advance
Link to comment
Share on other sites

  • 2 years later...

this code is bad, good is:

 

error_reporting(0); 
$old_error_handler = set_error_handler("userErrorHandler");
 
function userErrorHandler ($errno, $errmsg, $filename, $linenum,  $vars) 
{
$time=date("d M Y H:i:s"); 
// Get the error type from the error number 
$errortype = array (1    => "Error",
2    => "Warning",
4    => "Parsing Error",
8    => "Notice",
16   => "Core Error",
32   => "Core Warning",
64   => "Compile Error",
128  => "Compile Warning",
256  => "User Error",
512  => "User Warning",
1024 => "User Notice");
$errlevel=$errortype[$errno];
 
//Write error to log file (CSV format) 
$errfile=fopen("errors.csv","a"); 
fputs($errfile,"\"$time\",\"$filename: 
$linenum\",\"($errlevel) $errmsg\"\r\n"); 
fclose($errfile);
 
if($errno!=2 && $errno!=8) {
//Terminate script if fatal error
die("A fatal error has occurred. Script execution has been aborted");
} 
}

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...