W
W
WebDev2019-06-04 14:16:48
PHP
WebDev, 2019-06-04 14:16:48

How is the thread blocked?

Please explain how scripts work, for example, in PHP.
Let's say I have a script that takes a very long time to run, like this one:

$end = strtotime('+20 seconds');
while(time() < $end) {
//пустой цикл на 20 секунд
}
echo 'Loop is finished';

A visitor comes to the site, the web server runs this script for him and the visitor waits until it is executed.
At this time, the second visitor arrives, the third, and so on.
What is being created at this time? How many such visitors can enter at the same time? What does it depend on?
Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
sim3x, 2019-06-04
@kirill-93

http - stateless protocol
The browser requested a page from nginx - received it
Nginx has a time limit, how long it will wait until it returns a response to the
nginx user, if it is specified in its config, it sends a request via various protocols to contractors
For example php-fpm
PHP fpm has settings
The settings have their own limits on the response time and the number of processes that are simultaneously ready to process a request from nginx,
In your case, with default timers, the user will have at least 20 seconds of a white page and it will be indicated that the browser is waiting for a server response

I
Ivan Shumov, 2019-06-04
@inoise

yes, for each user, a parallel stream is simply created via php-fpm as a rule. this is not Nodejs, python or Java where one process is launched to which everyone is knocking

I
igorzakhar, 2019-06-04
@igorzakhar

algolist.manual.ru/web/servers.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question