News Feed
Jobs Feed
Sections




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

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


blog comments powered by Disqus

Similar Posts

Slawek Lukasiewicz's Blog: PHP application diagnostics - Memtrack

DevShed: Introducing the Composite Pattern in PHP 5

Felix Geisendofer's Blog: Screencast #1: Using vendor branching and CakePHP

DevShed: A Custom Exception Class for Dynamic Twitter Signature Images with PHP

php|architect: Two New ART Articles (CakePHP and More Flex)


Community Events











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


code example symfony2 podcast application release component install hack overview composer language introduction hhvm framework security facebook package opinion unittest

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