News Feed
Jobs Feed
Sections



Recent Jobs

News Archive
Perplexed Labs Blog:
PHP Forking to Concurrency with pcntl_fork()
March 10, 2010 @ 13:05:59

On the Perplexed Labs blog there's a recent post looking at how to fork processes in PHP with the help of the pcntl_fork function and the process management extension.

Let's say you want to take advantage of more than one core for a given process. Perhaps it performs many intensive computations and on a single core would take an hour to run. Since a PHP process is single threaded you won't optimally take advantage of the available multi-core resources you may have. Fortunately, via the Process Control (PCNTL) extension, PHP provides a way to fork new child processes.

He gives a quick snippet of code showing how to spawn off a few new processes, get their process IDs and watches a max number of children until one dies (then starts another).

0 comments voice your opinion now!
process control extension tutorial concurrency pcntlfork



Similar Posts

DevShed: Using Static Methods to Build Loader Apps in PHP

DevShed: Defining Public and Protected Methods with Member Visibility in PHP 5

Larry Garfield's Blog: Good SPL intro

IBM developerWorks: Cook up Web sites fast w/CakePHP, Part 1: Adding related information & services

ProDevTips Blog: Fluent Arrays and Strings in PHP


Community Events

phpnw10 PHP Conference 09/10/2010




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


symfony plugin developer development example unittest conference job book database framework application podcast suggestion wordpress codeigniter opinion curl zendframework phpunit

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