Examples of PHP concurrency using different libraries
website
Amphp parallel -Provides true parallel processing for PHP using multiple processes or native threads, without blocking and no extensions required.
If ext-parallel
is installed, it will use threads, otherwise it will use processes.
Pro: can change concurrency level.
$pool = new Amp\Parallel\Worker\DefaultPool(3);
website
Spatie async -wrapper around PHP's PCNTL extension.
Requires ext-pcntl
, Linux only. Uses processes.
Pro: can change concurrency level.
$pool = Spatie\Async\Pool::create()->concurrency(3);