When running PHP with Apache I know that the php core and all libraries are loaded for each request. However, with PHP CGI, FastCGI, or using PHP-FPM the php process persists for generally 500-1000 requests before it's restarted.
During that time, how does it handle loaded PHP classes or libraries?
Lets say I have a file that loads a massive library, will it load (then dump) the large library every request or keep it loaded for each new request I pass it?
By "loaded" I mean the classes are included (and parsed) but no objects are created.
How does APC play into this?
For FCGI (PHP-FPM is FCGI as well), only the php binary and it's binary libraries stay in memory. The PHP user-code does not.
During that time, how does it handle loaded PHP classes or libraries?
Kicks them off, get's them new on a new request. You can easily test that by setting global variables, they are gone at the beginning of the new request.
So the answer to your (bold) question is Let's straight-forward answer: Yes, it get's loaded and dumped per each request, no or! :)
APC does the same. I need to research a link, there is a webserver written in PHP so it can keep everything in memory. Give's you the real speed, however your applications code must properly deal with the changed request logic then.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With