开发者

How does PHP as a CGI handle memory?

开发者 https://www.devze.com 2023-04-01 09:43 出处:网络
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 re

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号