2 ms·
> Mind also: With a CGI process for each request the process has to be created, program loaded, runtime linked and executed. Yeah, that's CGI though, FCGI alle
by klingonopera 7y ago
> Mind also: With a CGI process for each request the process has to be created, program loaded, runtime linked and executed.
Yeah, that's CGI though, FCGI alleviates this by persistently running a single process/service/application that listens to the port and acts according to the received HTTP headers.
Whatever PHP can optimize can thus be done directly with FCGI as well. You can load everything the webpage needs into memory and just pipe that through to the user, and it would only need to read disk once at startup (or if you update the sources, but that's another issue).
The downside is of course the increased development time and complexity you'd have to invest...
EDIT2: Another downside specific to FCGI is that it is OS-dependent, because it needs to interact with the host in order to listen to a port, something that doesn't affect normal CGI because all you need there is stdout.
- johannes1234321 7y agoAnd and if you scrap it and build some custom webserver or nginx plugin or Apache module it can be even faster or maybe something like IncludeOS which makes your application logic part of a minimal kernel ... If that's your aim. In most cases development time however is more valuable than pure execution time. (Even Facebook survived quite long in PHP, till it was wothwhile for them to move to their own thing) Anyways comparison by GP was between a custom CGI program and PHP and not other things.
- klingonopera 7y agoThanks for IncludeOS, that sounds interesting... On Facebook: I'm willing to bet a switch to binary from PHP is one magnitude less of processing power required, and an early switch would've cut their server requirements by 90%. Not sure which would've been cheaper, the C devs or all those extra servers burning electricity to interpret a language during runtime. EDIT: And that's just an economic incentive. From an ecological perspective, it's borderline criminal for a website as massive as Facebook to be running PHP.
- johannes1234321 7y agoBy switching to HipHop for PHP and later HHVM they saved lots of servers. 90% is a bit too much (consider: they went "services" first, where different tasks were done in different languages in independent services) And yes, for the ecological argument that is true (even more ecological it would be to shut down Facebook ... ) However using PHP allowed them to hire lots of staff quickly and adapt to changed requirements quickly. Which is economical valuable. Finding the right time for a switch is simpler in a retrospective though ;-) (I have no insight to Facebook, but was heavily involved in the PHP project and talked to different Facebook engineers privately and professionally)