views:

131

answers:

2

Hiya All,

I am currently running a script that i've created in PHP that parses and sorts out 6 different xml files of around 40mb each.

I currently run the script through a browser, and a cron job to wget the page.

But sometimes with the server load it can clog up apache and and the rest of the server, Would it make sense to convert it to PHP CLI and make it purely command line? Would this improve performance? is it worth the time to do?

The script merely finds all the data it needs, formats, sorts and then places into MySQL.

So PHP CLI or PHP Web?

Thanks in advance.

Shadi

A: 

Yes. Especially if you use SAX or the PHP pull-parser to read the XML, so that you are not loading the entire file in memory. It would also not tie up apache's resources.

Jeff Ober
+2  A: 

PHP CLI.

It makes no sense to tie up apache's resources for this.

That said, it is no guarantee that your script will not slow your server down, since that depends on the actual script that's being executed.

Parsing a few such xml files and storing their contents, should not pose much of a problem on modern hardware. Even if the script isn't highly optimised.

Try and load as little data at once, and properly clean up used resources after use, to reduce memory consumption. Use extensions for xml-parsing to reduce load.

stroop