Laravel Concurrency Facade &amp; Process Pools | Mohamed Said        [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://www.msaied.com) [ Home ](https://www.msaied.com) [ Projects ](https://www.msaied.com/projects) [ Articles  ](https://www.msaied.com/articles) [ Certificates ](https://www.msaied.com/certificates) [ Contact ](https://www.msaied.com#contact-section) 

       [  ](https://github.com/EG-Mohamed)       

 [ Home ](https://www.msaied.com) [ Projects ](https://www.msaied.com/projects) [ Articles ](https://www.msaied.com/articles) [ Certificates ](https://www.msaied.com/certificates) [ Contact ](https://www.msaied.com#contact-section) 

  [ home ](https://www.msaied.com)    [ articles ](https://www.msaied.com/articles)    Concurrency in Laravel: Process Pools, Fibers, and the Concurrency Facade        On this page       1. [  Why Concurrency Matters Before You Reach for a Queue ](#why-concurrency-matters-before-you-reach-for-a-queue)
2. [  The Concurrency Facade ](#the-concurrency-facade)
3. [  What Gets Serialized ](#what-gets-serialized)
4. [  Process Pools for Lower-Level Control ](#process-pools-for-lower-level-control)
5. [  Timeouts and Error Handling ](#timeouts-and-error-handling)
6. [  PHP Fibers: Cooperative Concurrency Without Forking ](#php-fibers-cooperative-concurrency-without-forking)
7. [  Production Considerations ](#production-considerations)
8. [  Key Takeaways ](#key-takeaways)

  ![Concurrency in Laravel: Process Pools, Fibers, and the Concurrency Facade](https://cdn.msaied.com/471/ba1a628c196e92cbb81033c865c9ad26.png)

  #laravel   #concurrency   #php   #performance   #process-pools  

 Concurrency in Laravel: Process Pools, Fibers, and the Concurrency Facade 
===========================================================================

     26 Jul 2026      4 min read    ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said  

       Table of contents

1. [  01   Why Concurrency Matters Before You Reach for a Queue  ](#why-concurrency-matters-before-you-reach-for-a-queue)
2. [  02   The Concurrency Facade  ](#the-concurrency-facade)
3. [  03   What Gets Serialized  ](#what-gets-serialized)
4. [  04   Process Pools for Lower-Level Control  ](#process-pools-for-lower-level-control)
5. [  05   Timeouts and Error Handling  ](#timeouts-and-error-handling)
6. [  06   PHP Fibers: Cooperative Concurrency Without Forking  ](#php-fibers-cooperative-concurrency-without-forking)
7. [  07   Production Considerations  ](#production-considerations)
8. [  08   Key Takeaways  ](#key-takeaways)

 Why Concurrency Matters Before You Reach for a Queue
----------------------------------------------------

Queues are the right tool for deferred, durable work. But sometimes you need to fan out several independent HTTP calls, database reads, or CPU-bound transforms *right now*, within a single request, and collect the results before responding. Laravel's `Concurrency` facade (introduced in Laravel 11) and the underlying `Process` facade give you two clean primitives for this.

---

The Concurrency Facade
----------------------

The `Concurrency` facade runs an array of closures in parallel using forked PHP processes under the hood. Each closure is serialized, executed in a child process, and the results are collected back into the parent.

```php
use Illuminate\Support\Facades\Concurrency;

[$prices, $inventory, $reviews] = Concurrency::run([
    fn () => PricingService::fetch(productId: 42),
    fn () => InventoryService::fetch(productId: 42),
    fn () => ReviewService::summary(productId: 42),
]);

```

All three calls happen in parallel. The parent blocks until every child finishes, then returns results in the same order as the input array.

### What Gets Serialized

Because each closure runs in a forked process, anything captured in the closure must be serializable. Eloquent models, DTOs, and scalar values are fine. Database connections, open file handles, and non-serializable objects are **not** — they will cause silent failures or exceptions.

```php
// ✅ Safe — scalar captured
$id = $product->id;
Concurrency::run([fn () => SomeService::fetch($id)]);

// ❌ Unsafe — Eloquent model captured directly
Concurrency::run([fn () => SomeService::fetch($product)]);

```

---

Process Pools for Lower-Level Control
-------------------------------------

When you need more control — custom environment variables, timeouts, or shell commands — the `Process` facade's pool API is the right layer.

```php
use Illuminate\Support\Facades\Process;

$results = Process::pool(function ($pool) {
    $pool->command('php artisan report:generate --type=sales');
    $pool->command('php artisan report:generate --type=inventory');
    $pool->command('php artisan report:generate --type=returns');
})->start()->wait();

foreach ($results as $result) {
    if ($result->failed()) {
        logger()->error($result->errorOutput());
    }
}

```

Each `command` runs as a real OS process. `start()` launches them all immediately; `wait()` blocks until every process exits and returns a `ProcessPoolResults` collection.

### Timeouts and Error Handling

```php
Process::pool(function ($pool) {
    $pool->timeout(30)->command('php artisan export:csv --month=2025-05');
    $pool->timeout(10)->command('php artisan notify:slack');
})->start()->wait();

```

A timed-out process throws `ProcessTimedOutException` on `wait()`. Wrap the call in a try/catch and decide whether to retry or degrade gracefully.

---

PHP Fibers: Cooperative Concurrency Without Forking
---------------------------------------------------

Fibers (PHP 8.1+) are cooperative, not preemptive — they do not give you true parallelism. They are useful for interleaving I/O-bound work within a single thread, which is exactly how async libraries like ReactPHP and Revolt use them. Laravel itself uses Fibers internally in some Octane contexts.

For most Laravel applications, reach for `Concurrency::run()` or `Process::pool()` before writing raw Fiber code. Fibers shine when you control the event loop; in a standard FPM request, forked processes are simpler and safer.

---

Production Considerations
-------------------------

- **Worker limits**: Each forked process inherits the parent's memory footprint. On a 512 MB container, running 10 concurrent forks can exhaust memory quickly. Benchmark your payload size.
- **Database connections**: Child processes do not inherit open PDO connections safely. Let each child open its own connection via the service container.
- **Octane compatibility**: Under Octane, forked processes can inherit shared state. Prefer `Process::pool()` with artisan commands when running under Octane to avoid state leakage.
- **Observability**: Exceptions in child processes surface as serialized `Throwable` instances. Log them explicitly — they will not bubble up to your default exception handler automatically.

---

Key Takeaways
-------------

- Use `Concurrency::run()` for parallel PHP closures when results are needed immediately in the same request.
- Capture only serializable values in closures — never raw Eloquent models or connections.
- Use `Process::pool()` when you need OS-level process control, timeouts, or shell commands.
- PHP Fibers are cooperative, not parallel — they are not a replacement for process-based concurrency in FPM.
- Always account for memory multiplication and connection limits when sizing concurrent workloads.

 Found this useful?

          [  ](https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.msaied.com%2Farticles%2Fconcurrency-in-laravel-process-pools-fibers-and-the-concurrency-facade&text=Concurrency+in+Laravel%3A+Process+Pools%2C+Fibers%2C+and+the+Concurrency+Facade) [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fwww.msaied.com%2Farticles%2Fconcurrency-in-laravel-process-pools-fibers-and-the-concurrency-facade) 

 Frequently Asked Questions 
----------------------------

  3 questions  

     Q01  Does Concurrency::run() work under Laravel Octane?        It can, but forked processes inherit the parent worker's state, which can cause subtle bugs with shared singletons or open connections. Under Octane, prefer Process::pool() with artisan commands to get clean process isolation. 

      Q02  What happens if one closure in Concurrency::run() throws an exception?        The exception is serialized and re-thrown in the parent process when results are collected. Other closures that already completed are not rolled back, so design each unit of work to be independently safe to fail. 

      Q03  Is there a limit to how many closures I can pass to Concurrency::run()?        There is no hard framework limit, but each closure spawns a forked process. Practical limits come from OS process limits, available memory, and file descriptor counts. Keep pools small (2–8 tasks) and benchmark under realistic load. 

  Continue reading

 More Articles 
---------------

 [ View all    ](https://www.msaied.com/articles) 

 [ ![Filament v4 Migrating from v3: Breaking Changes and Refactor Patterns](https://cdn.msaied.com/472/bb7fbf8441c775fcfadd23850e1756e8.png) filament laravel migration 

### Filament v4 Migrating from v3: Breaking Changes and Refactor Patterns

A practical, opinionated guide to the most impactful Filament v3→v4 breaking changes: schema-based forms, the...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 26 Jul 2026     4 min read  

  Read    

 ](https://www.msaied.com/articles/filament-v4-migrating-from-v3-breaking-changes-and-refactor-patterns) [ ![Laravel Queues in Production: Horizon Tuning, Metrics, and Graceful Scaling](https://cdn.msaied.com/470/afd2bee56d15842d72c1c6d5c238d236.png) laravel horizon queues 

### Laravel Queues in Production: Horizon Tuning, Metrics, and Graceful Scaling

Go beyond basic queue setup. Learn how to tune Horizon supervisor processes, interpret queue metrics, handle b...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 26 Jul 2026     3 min read  

  Read    

 ](https://www.msaied.com/articles/laravel-queues-in-production-horizon-tuning-metrics-and-graceful-scaling) [ ![Laravel Horizon: Queue Metrics, Supervisor Tuning, and Graceful Scaling in Production](https://cdn.msaied.com/469/ebbc461b808da425a418bf6ffc998d7a.png) laravel horizon queues 

### Laravel Horizon: Queue Metrics, Supervisor Tuning, and Graceful Scaling in Production

Beyond the dashboard: how to tune Horizon supervisors, interpret queue metrics, and scale workers gracefully w...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 25 Jul 2026     3 min read  

  Read    

 ](https://www.msaied.com/articles/laravel-horizon-queue-metrics-supervisor-tuning-and-graceful-scaling-in-production-1) 

   [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://www.msaied.com)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

Explore

- [Home](https://www.msaied.com)
- [Projects](https://www.msaied.com/projects)
- [Articles](https://www.msaied.com/articles)
- [Certificates](https://www.msaied.com/certificates)
- [Contact](https://www.msaied.com#contact-section)

Connect

- [   hello@msaied.com ](mailto:hello@msaied.com)
- [   +20 109 461 9204 ](tel:+201094619204)

© 2026 Mohamed Said. All rights reserved.

 [  ](https://github.com/EG-Mohamed) [  ](https://www.linkedin.com/in/msaiedm/) [  ](https://wa.me/201094619204) [  ](mailto:hello@msaied.com) [  ](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
