hhxsv5 / laravel-s

LaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.
MIT License
3.82k stars 471 forks source link

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

Open fakharak opened 1 year ago

fakharak commented 1 year ago
  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 ?

hhxsv5 commented 1 year ago

About Coroutine In LaravelS