News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Ibuildings Blog:
Boost performance with parallel processing
January 23, 2009 @ 07:51:05

On the Ibuildings blog today there's a new post from Martin Roest looking at parallel processing in PHP scripts and how it can help you with performance and simplifying your applications.

The idea of parallel processing is when you take an atomic transaction or operation called a 'process' and run a couple of those at the same time. [...] In this example I had a PHP CLI script. The purpose of this script was to process remote documents and save it local. It fetched the document from a remote location, processed it and saved the result local - let's call this the transaction. Transactions were done sequentially. It took about 1 second for a transaction to complete and the script had to do roughly 3500 transactions.

Obviously, this script/testing method was not very effective, so he went searching for an alternative. The best option came in the shape of forking processes - spawning off a separate script (via PHP's forking functionality) to do the work on one or multiple entries. It uses the pcntl_fork and pcntl_waitpid functions to spawn and manage these children. Once they're all finished - working in parallel - they return back to the main script to wait for the slower ones to catch up.

0 comments voice your opinion now!
performance boost parallel processing ibuildings fork pcntlfork pcntlwaitpid


blog comments powered by Disqus

Similar Posts

Shashikant Jagtap: Automating Web Performance Data Collection with Behat and BrowserMob Proxy

Ibuildings Blog: Building a PHP Center of Expertise

PHP-Coding-Practices.com: The Opening Of A New PHP Directory!

Christopher Jones' Blog: Oracle & PHP Users: don't miss the Zend Conference

PHPClasses.org Blog: Distributing PHP processing with Gearman


Community Events

Don't see your event here?
Let us know!


library framework opinion development video voicesoftheelephpant release introduction laravel conference interview psr7 unittest podcast laravel5 extension series language api community

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework