Today I came across the following statement from PHP Manual:
The web server runs only one single-threaded process, so PHP applications will stall if a request is blocked.
After reading and trying to understand the above statement firstly I didn't understand the actual and exact meaning of the term single-threaded process specific to PHP.
Secondly, I didn't understand the second part of this statement as below
so PHP applications will stall if a request is blocked.
I didn't understand what request gets blocked when and how? Which PHP applications get stalled?
So, can someone please explain to me the actual and exact meaning of the above entire statement with specific meaning to PHP and with a suitable example?
PHP's web server cannot process multiple requests at the same time. It's single-threaded and doesn't spool additional processes like Apache or Nginx do.
Let's say you start the web server and it listens on
localhost:8080. You write the following code as the only logic:You then open two tabs in your browser and you navigate to
localhost:8080in both tabs at the same time. The first tab shows content after 5 seconds, while the second one is stalled until the first one finishes and then takes another 5 seconds to execute. This means that the second tab will show content only after 10 seconds.