

In fact, it's considered to be one of the perks of using PHP.
Php fpm workers code#
That's all work that must be done for every request before your actual application code is executed.įor the vast majority of web applications, this is not a problem. That includes bootstrapping Laravel by registering container bindings and booting Service Providers. However, the worker still has to execute the script ( /public/index.php) for every request. This makes request handling much faster, because the PHP worker won't have to interpret the PHP script each time. For that reason, production servers use OPcache to only compile the PHP code once, after the first request, and store it in the server memory to be reused by Zend engine later. Doing this for every request costs time and machine resources. So PHP compiles its code to op codes and passes them to a scripting engine (Zend Engine) that is used to execute them. Now a server doesn't understand instructions written in PHP. Each worker can execute a single request at any given time. Once a request is received, the worker is going to execute the script ( /public/index.php in the case of Laravel) and return the response. A worker starts by initializing PHP and all its installed extensions and then waits for requests. PHP-FPM starts and manages a pool of PHP workers whose job is to handle incoming requests. The FPM master process will assign a PHP worker to handle the request and then send the response back. In a typical LEMP stack setup, Nginx is going to proxy the request to the PHP-FPM process through a UNIX socket.
