laravellaravel-octane

Is the number of "workers" in Laravel Octane equal to the number of requests that can be handled simultaneously?


Do I understand correctly that the number of "workers" in Laravel Octane is equal to the number of requests that can be executed simultaneously?

For example, if there are 2 workers, and 2 of them are busy returning CSV exports - new requests will not be processed?

What's the situation like with concurrency in Laravel Octane?


Solution

  • Octane with RoadRunner or Swoole

    When Octane is used with RoadRunner or Swoole, the number of workers is directly responsible for the number of requests your app can handle simultaneously. You can verify it with following route:

    Route::get('longrequest', function () {
        sleep(15);
        return 'done';
    });
    

    If you spin a Laravel Octane instance with 2 workers and hit this endpoint twice, the third execution will have to wait until one of the two workers becomes free to process it.

    Octane with FrankenPHP

    By default, this also applied to FrankenPHP.

    Hovewer, in FrankenPHP, it's possible to set max_threads to auto, and it would then auto-scale the number of workers.

    https://frankenphp.dev/docs/performance

    Other alternatives

    In case you want something Laravel-like and truly asynchronous, check out Hypervel.