1

I'm testing two versions of the same script. Each script does the same operation but they differ in how they output the result. Each script:

  1. Loads a local image using imagecreatefrompng()
  2. Adds text to image using imagettftext()

The first script outputs the final image this way:

imagepng($img, $cacheFile, $quality);
imagedestroy($img);
$fp = fopen($cacheFile, 'rb');
header("Content-Type: image/png");
header("Cache-Control: no-cache, must-revalidate"); 
header("Pragma: no-cache");
header("Content-Length: " . filesize($cacheFile));
header('Content-Transfer-Encoding: binary');
ob_end_clean();
fpassthru($fp);

2nd script:

header('Content-Type: image/png');
imagepng($img, null, $quality); 
imagedestroy($img);

Both scripts work well when I call them directly in the browser and I get the expected result. But when I use JMeter for load testing of each one, I often get a non-descriptive 500 errors in response in each script.

The error_log file, which is normally created when there are errors in the script, is not present.

How can I troubleshoot the cause of the 500 error? Is there a way to know if it's the shared hosting cutting off resources and that's why scripts fail to execute or if it's something else? How can I optimize my scripts for best performance during a heavy load?

miken32
  • 42,008
  • 16
  • 111
  • 154
Alex E
  • 735
  • 2
  • 7
  • 15
  • May not be your script at all, but a shared hosting, either some problem with it, or even some sort of defense against too many requests from the same host. I think the best test would be setting up your own web server and test on it. – timbre timbre Jun 04 '16 at 02:28

1 Answers1

0

I ended up rewriting to C# and deploying to Azure

Alex E
  • 735
  • 2
  • 7
  • 15