Re: Why FastCGI?

[email protected] (Jose Nobile)
Newsgroups php.general
Message-ID <CAJ69RUQmrAd=MPzsu2E2PNT21T4vyyMw7NLmk-GbNAPA-LJ+-w@mail.gmail.com>
Hello,

To serve content from PHP by using HTTP in a professional way, there is a
need  http/2 <https://tools.ietf.org/html/rfc7540> + http/3 (quic
<https://quicwg.org/base-drafts/draft-ietf-quic-http.html>), to implement
it, an event handler/concurrency is needed, in the same way, the
professional HTTP servers do as Nginx
<https://www.nginx.com/blog/thread-pools-boost-performance-9x/#:~:text=In%20general%2C%20NGINX%20is%20an,system%20about%20what%20to%20do.>,
Litespeed Web Server
<https://www.litespeedtech.com/products/litespeed-web-server/features/event-driven-architecture>
or Cloudflare
<https://blog.cloudflare.com/how-we-scaled-nginx-and-saved-the-world-54-years-every-day/>

PHP natively has this support related to events/threads:

Events <https://www.php.net/manual/en/event.examples.php#example-4709> /
libeio <https://www.php.net/manual/en/intro.eio.php>
Parallel <https://www.php.net/manual/en/class.parallel-events.php>
pthread <https://www.php.net/manual/en/intro.pht.php>
libev <https://www.php.net/manual/en/intro.ev.php>

Such extensions don't have an integrated HTTP/2 server, it why there are
third party extensions with such support as:

Swoole (HTTP/2 + Websocket)
<https://github.com/swoole/swoole-src#mixed-server>

Or Frameworks:

amphp/http-server <https://github.com/amphp/http-server>

It is the closest you can serve content from PHP to a browser by using
HTTP/2, similar to the Node.js HTTP/3 server
<https://www.nearform.com/blog/a-quic-update-for-node-js/> OR Node.js
HTTP/2 server <https://nodejs.org/api/http2.html>

But, I do not recommend serving HTTP content directly from PHP, the core
PHP developers only have reached a dev HTTP server
<https://www.php.net/manual/en/features.commandline.webserver.php>, it's
due to event/threads in PHP still not safe for enterprise, instead, the
best connector so far isn't FPM, it is LSAPI
<https://www.litespeedtech.com/open-source/litespeed-sapi/php> based on
this benchmark <https://www.litespeedtech.com/benchmarks/php-hello-world>

Disclaimer: I have no relation with any of the companies linked here.

Regards,
Jose Nobile


On Sun, Mar 21, 2021 at 10:59 AM Gunter Grodotzki <[email protected]>
wrote:

> > FastCGI or something like that to execute the compiler.
>
>
>
> Yes exactly – “or something like that” is my question. Why FastCGI?
>
>
>
> This is especially given, that I see no other “modern” programming
> language or framework going down that route. You do not _*need*_ FastCGI,
> its just the _*current*_ choice of protocol for communications between
> HTTP (Server) <> Script.
>
>
>
> Hope my questioning is a bit clearer now. Again: I know what FastCGI is
> and what it does on a high-level. But would like to know why HTTP is not
> being considered.
>
>
>
> Cheers,
>
> Gunter
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.