🇬🇧 English 🇧🇬 Български

How PHP-FPM Really Works

Client → Nginx → PHP-FPM → Worker Pool → PHP Process → Response

Автоматична, бавна и циклична визуализация на request lifecycle-а. Гледай как заявките текат през системата и как worker pool-ът определя реалния concurrency.

Slow Fast 1.0×
REQ #1 · /index.php REQ #2 · /report (slow) REQ #3 · /index.php REQ #4 · /index.php REQ #5 · /index.php /style.css · static asset
CLIENTS
Browsers, apps & API callers sending HTTP requests
➜
NGINX
Static files → direct response
PHP files (.php) → FastCGI to PHP‑FPM
➜
PHP-FPM MASTER
Manages the worker pool. Does not run your PHP code itself.
➜
FPM LISTEN QUEUE
empty
Worker #1 FREE
waiting for request
Worker #2 FREE
waiting for request
Worker #3 FREE
waiting for request
0 / 3 WORKERS BUSY
Queue: 0 waiting
⚠ All PHP workers are BUSY
workers shown pre-forked for clarity — pm.start_servers / min / max_spare govern real-world scaling
PHP-FPM POOL: www
  • pmdynamic
  • pm.max_children3
  • pm.start_servers2
  • pm.min_spare_servers1
  • pm.max_spare_servers2
pm.max_children = maximum number of PHP requests that can execute concurrently in this pool.
WHAT'S HAPPENING NOW?
Waiting for the first request…
PHP-FPM0 / 3 workers busy
Queue0 waiting requests
Worker #2 (slow /report)idle
WHY IS A REQUEST WAITING?
No requests are currently waiting.
💡 Note: in PHP-FPM a worker stays BUSY for the entire request — including DB / network waits. Watch Worker #2 while it runs the slow /report request: it stays occupied the whole time. This is different from Node.js's non-blocking event loop, where one process can juggle many waiting requests at once.

THE ONE THING TO REMEMBER

Nginx can handle many connections
PHP requests go to PHP‑FPM
PHP‑FPM has a limited worker pool
1 request occupies 1 PHP worker
available workers determine PHP concurrency
if all workers are busy…
…new PHP requests wait in the queue
when a worker finishes
it becomes FREE and handles the next request