"Help" PHP sleep () causes all pages to be unresponsive.

Source: Internet
Author: User
PHP sleepx

Environment is LNMP, I wrote in the code
Sleep (60);
Open that page, 60 seconds before the output, this is normal;
But in these 60 seconds the other pages in my site are also loading, until this page appears,
Other pages appear ...

Then I in the code, the empty loop 10 million times, found that if the page is not finished;
The other pages are also the loading state;

Younger brother used to do Java, just contact PHP soon, this is too strange, please you greatly pointed out the maze


Reply to discussion (solution)

1. Is there a sleep () code in the program? Is there a similar session_start ()? Or you have modified the php.ini to open the session automatically.
If yes, that is the session file lock causes
2. What is the largest child process in your php-fpm? If there is only one, it will also cause congestion.

What is the specific code situation? Is there a for, Forreach loop?

1. Is there a sleep () code in the program? Is there a similar session_start ()? Or you have modified the php.ini to open the session automatically.
If yes, that is the session file lock causes
2. What is the largest child process in your php-fpm? If there is only one, it will also cause congestion.

The code does have session_start ().
But I closed the browser, and then reopened, it should be a new session, but the same can not open.
If it is a session file lock, how to solve it?

PHP-FPM the size of the maxspareservers is 35, do not know whether this configuration is reasonable



What is the specific code situation? Is there a for, Forreach loop?

I also used the loop, because the original intention is to let him break each cycle for a few seconds,
But without loops, sleep alone still has this problem.

If it is
foreach (...) {
......
Sleep (5);
}
What's wrong with this code?

This guessing game is not fun at all.

I also used the loop, because the original intention is to let him break each cycle for a few seconds,
But without loops, sleep alone still has this problem.
The problem should be in your loop code, which is suspected of a dead loop.
Instead of looping, use code like this to add up to an HTTP connection.

Main code area if () {//depending on your situation, whether you want to continue with  sleep (5);  $ch = Curl_init ();  curl_setopt ($ch, Curlopt_url, $url);//Curl re-opens your current page with a connection time of 1 seconds and 1 seconds to execute all code and exit the current page.  curl_setopt ($ch, Curlopt_returntransfer, 1);  curl_setopt ($ch, curlopt_connecttimeout, 1);   curl_setopt ($ch, curlopt_timeout, 1);  Curl_exec ($ch);  Curl_close ($ch);}

It's been a busy couple of days, no time.
Try a bit, is really a session file lock problem, I actively use the
Session_write_close ();
Other web pages are really open, mainly this project like to use the session to pass the page hints,
And I have no knowledge of the session implementation of PHP.

Ok, knot paste, thank dream1206 's advice, in a language, give 90.
The remaining 10 points, see a copy, thank you for your enthusiastic help.

Words, incredibly bz adults are attracted, not what companies can chat on the internet to the sister's good,
You think I don't want to stick to code ~ ~ And if I don't have a brain sticker, do you really want to see it?

OK, thank you for your continued support ~ ~

Thank you so much for solving the big problem.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.