In PHP Dies After Every Request. How the Zend Engine Actually Runs Your Code., S M Tahosin walks through a PHP request from source code to execution and cleanup. The walkthrough raises a practical question for anyone diagnosing a PHP-FPM deployment: which work starts over on every request, and which work can a later request reuse?
A worker can handle more than one request
A web server passes a request to an available PHP-FPM worker over FastCGI. The worker initializes the request context, runs the application code, and performs request shutdown. Ordinary script variables belong to that request. The worker can then return to its pool and handle another request, with fresh request data. In practice, the lifetime of a variable in the script and the lifetime of the operating system process are two different things to measure.
That distinction matters when investigating memory growth. The request shutdown described in the article covers request-scoped allocations. PHP-FPM also exposes a pool setting that limits how many requests a child handles before respawning, which the PHP manual identifies as useful when working around leaks in third-party libraries. Request cleanup and child recycling operate at different boundaries. PHP-FPM configuration
Compiled code can survive the request
Before PHP can execute a script, the Zend Engine turns the source into opcodes. Tahosin traces the intermediate steps from tokens to a syntax tree and then to the instructions the engine executes. With OPcache enabled, PHP can keep compiled script bytecode in shared memory and reuse it on later requests. A cache hit saves compilation work while each request still runs the instructions needed to compute its response. OPcache manual
Consider a route that reads one record and renders a page. A warm opcode cache can save the cost of compiling the route's PHP files. The request still has to perform the database lookup and render the result. When comparing a cold run with a warm one, how would the team isolate file compilation from database time and application execution?