Hacker News new | ask | show | jobs
by windowsworkstoo 4274 days ago
Wait, isn't that just if it's used/configured as a CGI? If you use it as a webserver module (Apache/IIS/Lightspeed), the execution environment can persist in a similar way to an app domain, right?
2 comments

Nope, it's still cleared at the end of the request (as it should be, this is not a bug or mis-feature, and is actually one of the things PHP got right for scalable apps).

What doesn't happen compared to CGI, IIRC, is loading the whole PHP engine from the start for every invocation. But no request specific memory is ever shared between invocations.

The only way to set PHP up as a daemon with shared execution and shared processes responding to requests is to use something like ReactPHP[0] -- even with mod_php, php5-fpm or similar, the execution context is still thrown away. The only difference between that and CGI is that the compiled byte code can be cached and the start-up costs are minimised as the bare interpreter process is kept around.

Shared-nothing turns out to be really nice for scaling web apps. One of the few things PHP got right from the get-go.

[0] http://reactphp.org