laravel-s icon indicating copy to clipboard operation
laravel-s copied to clipboard

Why not use Coroutine in Worker Processes ? since Swoole version 4.7.1 introduces new concurrency mode.

Open fakharak opened this issue 2 years ago • 1 comments

  1. Your software version (Screenshot of your startup)

    Software Version
    PHP TODO
    Swoole TODO
    Laravel/Lumen TODO

    PHP 8.1 OpenSwoole 4.11.1 Laravel 9.0 but any version

  2. Detail description about this issue(error/log)

Since OpenSwoole version 4.7.1 a new concurrency mode has been introduced which makes worker process reload after completing each request just like PHP-FPM, and it still allows to use coroutines (concurrency) within request. So the requests are served by the Worker Process in Synchronous way but within each request we can use co:create, or go().

That enables traditional PHP-FPM based PHP-Frameworks to make smooth transition to OpenSwoole without change.

To enable that mode, we just need to make coroutine setting as below: co::set([max_concurrency => 1]);

Question-1: Given the fact above, why not use coroutines in Swoole\Http\Server->on("request", callback() { }); in Larave-S ? Question-2: Where to put configuration for co::set() in Laravel-S ?

fakharak avatar Sep 26 '22 10:09 fakharak