PHP 8 interview question · Most asked

What happens to an HTTP request in a PHP-FPM application, and what does 'shared nothing' mean?

Summary

nginx passes the request to PHP-FPM over FastCGI; the master assigns it to an idle worker process; the worker runs the entry script (public/index.php) from the top: autoloading, framework bootstrap, routing, controller, response; then all request memory (variables, objects, static properties) is discarded. Nothing in application memory survives to the next request, only OPcache's compiled code, caches, sessions and databases.

Longer Answer

Each worker handles one request at a time, so capacity is workers divided by request time: slow outbound calls exhaust the pool (502/504) even when CPU is idle. Long-running runtimes (Octane, RoadRunner, FrankenPHP worker mode, Swoole) avoid repeated bootstrap but give up shared-nothing isolation, so request state can leak between requests.

Key Points

  • FastCGI → worker → script runs from the top.
  • All request memory discarded afterwards.
  • One request per worker; capacity = workers ÷ time.
  • Long-running runtimes trade isolation for speed.

Deep dive: Request Lifecycle course: PHP-FPM and the Shared-Nothing Model

Explanation

What interviewers look for

Understanding the per-request bootstrap and the capacity model.

More most-asked PHP 8 questions

← All PHP 8 questions