Open abertschi opened 4 years ago
Probably, we must leave this to the user level PHP scripts that implement SAPI or run as an Async server like https://www.swoole.co.uk/ or https://reactphp.org/
There are many exciting things to work on in this issue.
Some ideas:
https://stackoverflow.com/a/2772929 https://en.m.wikipedia.org/wiki/FastCGI https://news.ycombinator.com/item?id=24683304
It is easier to see how an event driven approach like the links you posted above can benefit from GraalVM's dynamic compiler because the event loop is modeled within PHP. One has to figure out how an approach with a mod_php like module or a fastCGI implementation can benefit from dynamic compilation. Graalphp's context must persist across requests to gather enough profiling feedback for dynamic compilation.
from a business perspective, people prefer PHP-FPM more than mod_php
Reasons:
To note: PHP supports a feature called preloading: https://www.php.net/manual/en/opcache.preloading.php
People are moving to Swoole and other implementations, cos classical PHP-FPM doesn't scale well when compared to other technologies like NodeJS
Swoole solves this by going async, but this introduces very ugly async code and you can't do anything other than plain IO, and as expected, any kind of image manipulation or simple CPU intensive task will block the entire event loop. You have to be a lot more careful when writing Async code.
The majority of the applications use classic PHP-FPM, and there is no real-world performance benefit even with the introduction of PHP-8-JIT, because the classical FPM is single-threaded and spawns child processes based on max child processes that you configure. A single FPM process will block as long as it finishes with the entire request.
This is one area, which we could improve on and deliver some real-world performance improvements,
PHP SAPI: https://github.com/php/php-src/tree/master/sapi