Skip to main content
InterviewHubPRO
Section Overview
Q2

Question 2 of 50

Part 1: Architecture, Service Container & Request Lifecycle (1 - 10)

4%
Laravel & Ecosystem (50 Qs)•Part 1: Architecture, Service Container & Request Lifecycle (1 - 10)

How does the PHP Execution Lifecycle work (CGI vs FastCGI vs PHP-FPM)?

senior LevelLifecycleDocker & ContainersSystem Design

In Simple Words: PHP traditionally runs in a Share-Nothing Architecture:

  1. Nginx receives an incoming HTTP request.
  2. Nginx forwards the request over a Unix Domain Socket to PHP-FPM (FastCGI Process Manager).
  3. PHP-FPM assigns the request to an idle pre-forked worker process.
  4. The worker boots the application, executes the PHP script, renders output, and sends the HTTP response back.
  5. Memory Clean: The worker process wipes all memory and state clean, ready for the next request! Zero memory leaks across requests, but requires bootstrapping the framework on every hit.