March 19, 2012

The mystery of slow XML loading - solved

Last week I've spent some time installing a VMWare hosted linux server onto my Windows 7 PC in the office, mostly because our development server is under a heavy load for several things, e.g. a Jenkins CI instance.
After some experimenting with Debian stable (squeeze) and testing (wheezy), I've ended up using Ubuntu Server 10.04 LTS, long story short because of the support from VMWare, and the available 2.6.x kernel (had network issues with the 3.2.x kernel).
It worked as a charm, installing the whole thing together with Apache, PHP5 and the required PHP modules didn't take more than 30 minutes, the testing phpinfo() page jumped into my browser like a squirrel on red bull.

I've checked out the source of one of our projects, stoked to see how it'd work with my VM. Set up virtual host, done. Configure app, done. Let's open it in a browser. Surprise! One page load took about 2 minutes. WTF?!?
OK, let's see CPU load on the VM. None.
OK, it must be HDD load then. None.
OK -I'm not giving up- the network is slow again. No.
OK, the VM apache is waiting for the response from database server. No.
OK, then what the fudge is happening? Let's run some benchmarks. Phpinfo page is loading like in no time.
OK, so it must be something with our stuff, but what? At this point I remembered that back in the old days I had a story with configuring the Exim MTA, and it had a network wait timeout...
OK, let's see what's happening on the network. After starting up iptraf, I've noticed that there's an external IP which is connected to the VM. The IP address is pointing to a w3c.org host, let's google that. And voila! after a few minutes I've learned that the PHP DOM extension is set to load the DTD for loading and parsing XML files... Our app has a setting to disable DTD loading, but I didn't like that idea, and a comment on a PHP documentation page said that the DTD's can be stored locally. At this point - 8.30PM, still in the office, feeling like a zombie - I've asked our lead developer - who was also still in the office :) - how can I have solve this thing. He pointed me to a package called w3c-dtd-xhtml holding the DTD's. After installing it, our app was running like crazy, no waiting, I could even copy the database from the dev server, and run it locally, it's still fast enough.

Today I've installed Apache on the Windows host, and set it up to reverse proxy the VM out for the others in the office, and it runs smoothly.

How could I be that stupid to say Windows when I was asked what OS I'd like to use on my PC, when almost everything I use for development is available on linux now...
... not that I wouldn't have the same issue on a linux desktop tho :)