954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Increasing PHP Instructions Per Second

I have made a PHP script which takes days to execute (Web Article Generator) and is there any way that I can make the while loops do more Instructions Per Second using php. Because when executing the script, the servers resources are very low (15% memory & about 9% of cpus) which means the server has plenty of room for a faster execution time. The only thing that I can think of so far is to have a page with 16 iframes all executing a separate while loop of the same php applet but I really need a PHP solution.
If you have any suggestions for increasing the Scripts Instructions Per Second or making the execution time faster then please post them.

cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

You can increase the memory limit in PHP which may help with the problem, see http://www.ducea.com/2008/02/14/increase-php-memory-limit/

If PHP is installed on a remotely managed server, this may not be an option depending on the build options used.

Will Gresham
Master Poster
755 posts since May 2008
Reputation Points: 96
Solved Threads: 125
 
ini_set('memory_limit','384M');

Surprisingly adding the line above seems to help a little but not tremendously. But is there anything which directly relates to the execution speed or speeds up the execution time to a much faster speed?

cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

Assume you have hardware that meets to run your script.

If so,
1. Optimize your SQL.
2. Install memcache extension in PHP.

Hope it helps.

PoA
Posting Whiz in Training
237 posts since Jul 2004
Reputation Points: 26
Solved Threads: 9
 

Thanks for the replies but I have just found out that it is mainly mysql query's that slow down the script big time. So I will try to use arrays and will try out memcache if memcache is a default php library.

cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

Another option is(I've never done it before but it should work) addresses by an article that I read about six months ago regarding php multi threading. This can be done with an tag. For instance, if you want to send any number of parallel threads on their own, you can create an html page with several processor.php?var1=var1value&var2=var2va and then do a javascript redirect at the bottom to continue processing. It would probably take some working with to perfect the process but if used correctly could probably cut processing time drastically.

R0bb0b
Posting Shark
998 posts since Jun 2008
Reputation Points: 358
Solved Threads: 89
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You