Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem with my apache2 server and I'm not quite sure how to best debug it.

What I'm seeing:

  • I've got a PHP script that renders a barcode. When this script is requested externally to the server the response is as you'd expect (> 1 sec)
  • I'm using the output from the script in another script on the same server, to embed the barcode in another image using GD. For some reason, the request to fetch the barcode image using PHP (specifically using imagecreatefrompng()) is very slow ~ 15-20 seconds at least

How would I debug this issue? I've had a bit of a google and best guess so far is slow DNS lookup - how would I check this best? And if it's the case, what's the easiest fix?

Edit: The reason I'm fairly certain that the issue is related to requesting the image from the first script is that the second script runs very slow if the extra image is requested, but fast if the image is not requested. The barcode getting embedded is not the only image rendering going on (there's a fair amount of text rendering and image copying happening) but it's only when I include the barcode that the slow-down happens.

share|improve this question
How are you calling it from the local script? php CLI binary, or wget to the local webserver? – Kyle Smith Mar 26 '12 at 15:05
Well, essentially both scripts are called with http requests. Script 1 renders a .png file and serves it up as image/png. Script 2 is also invoked through http (through the browser) - it just uses imagecreatefrompng() in php to open the .png file rendered by script 1 directly (so no need to share paths). – Fake51 Mar 26 '12 at 15:33

Do you know if the issue is happening when the image rendering or the php code?

If it's in the php you can installed some accelerators like APC or use some zend functions to speed up delivery. If it's in the image rendering you may be hitting cpu/memory limitations. What does your load average look like when you run top. What about when you type free. Are you hitting the disk cache. All of this can be directly related to performance.

I guess what I am suggesting is try to figure out if this is a software issue or hardware/resources issue and attack it from there. Best of luck!

share|improve this answer
Interesting suggestion. I'll try debugging that with an exec() call to wget, to see if image rendering in the second script is the bottleneck or the inclusion. – Fake51 Mar 26 '12 at 15:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.