- use mod_php which must start an interpreter instance for each request and has to dump all associated resources (db handle and the like) and memory when the request is served
- use something like FPM that has a pool of workers ready to communicate with the web server, which is more or less what every other languages do, if not via fast-cgi just by proxying an application server
Another way is event-driven, async PHP application server, but again it's not any different than similar solutions in other languages.
Now why people think PHP is low-resource ? That's all rose tinted glasses, because back in the days when everyone just used mod_php on cheap shared hosting for low-traffic websites, the execution model made it possible to get away with leaky apps since all memory was flushed at the end of the request.
If you want to go low-resource, use something like Go which is both much faster than PHP and has a lower memory footprint or choose an execution model that shares resources between requests (available in any JS, Python, Ruby, whatever you like).
- use mod_php which must start an interpreter instance for each request and has to dump all associated resources (db handle and the like) and memory when the request is served
- use something like FPM that has a pool of workers ready to communicate with the web server, which is more or less what every other languages do, if not via fast-cgi just by proxying an application server
Another way is event-driven, async PHP application server, but again it's not any different than similar solutions in other languages.
Now why people think PHP is low-resource ? That's all rose tinted glasses, because back in the days when everyone just used mod_php on cheap shared hosting for low-traffic websites, the execution model made it possible to get away with leaky apps since all memory was flushed at the end of the request.
If you want to go low-resource, use something like Go which is both much faster than PHP and has a lower memory footprint or choose an execution model that shares resources between requests (available in any JS, Python, Ruby, whatever you like).