Menu

1 / 2

PHP async: event loop, Fibers and the limits of single-threading

DEV Community·Odilon HUGONNOT·6 months ago
#iRSLkQoT
#php#async#reactphp#loop#fiber
Reading 0:00
15s threshold

A colleague asks: "Can PHP do what Node.js does — jump between tasks on a single thread?" Short answer: yes. Long answer: it's more subtle than that, and the distinction between concurrency and parallelism changes everything.

PHP has a reputation for being sequential and blocking. That's true in the classic Apache + PHP-FPM model. But it's far from inevitable — understanding why it blocks is the first step toward knowing when and how to stop letting it.

The blocking model of PHP-FPM

In PHP-FPM, each HTTP request is handled by an isolated worker. That worker is single-threaded: operations execute one after another, in order.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.