[Help] phpsleep () causes no response from all webpages

Source: Internet
Author: User
[Help] phpsleep () causes all webpages to fail to respond to php sleep ×

The environment is lnmp. I wrote it in the code.
Sleep (60 );
The page is opened and output is available 60 seconds later. this is normal;
However, in the past 60 seconds, all other webpages on our website are in the loading status until this page appears,
Other pages appear...

Then, in the code, I made a null loop for 10 million times and found that if the page was not executed completely;
Other pages are also in the loading status; this is so strange...

The younger brother was a java Engineer. he just got in touch with php. this is so strange. please give me some advice.


Reply to discussion (solution)

1. is there only one sleep () code in the program? Is there session_start ()? Or you have modified php. ini to enable auto-enable session.
If yes, it is caused by the session file lock.
2. what are the largest sub-processes in your php-fpm? If there is only one, it will also cause congestion.

What is the specific code? Is there a for or forreach loop?

1. is there only one sleep () code in the program? Is there session_start ()? Or you have modified php. ini to enable auto-enable session.
If yes, it is caused by the session file lock.
2. what are the largest sub-processes in your php-fpm? If there is only one, it will also cause congestion.

Session_start () exists in the code ().
But I closed the browser and re-opened it. it should be a new session, but it cannot be opened.
If it is a session file lock, how can this problem be solved?

The size of MaxSpareServers in php-fpm is 35. I wonder if this configuration is reasonable.



What is the specific code? Is there a for or forreach loop?

I also used loops, because the original intention was to let him rest for several seconds in each loop,
But there is no need to loop, and only sleep still has this problem.

If yes
Foreach (...){
......
Sleep (5 );
}
Is there any problem with this code?

This guessing game is not fun at all.

I also used loops, because the original intention was to let him rest for several seconds in each loop,
But there is no need to loop, and only sleep still has this problem.
The problem should be in your loop code, which is suspected of endless loops.
It is better not to use loops. use code like this to add up to one HTTP connection.

// Main code area if () {// determine whether to continue executing sleep (5) according to your situation; $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ url); // curl re-opens your current page. the connection time is 1 second. After 1 second, all code is executed and the current page is exited. Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, 1); curl_setopt ($ ch, CURLOPT_TIMEOUT, 1); curl_exec ($ ch ); curl_close ($ ch );}

These two days are too busy to come up.
I tried it. it is indeed a session file lock problem. I took the initiative to use it.
Session_write_close ();
Other web pages can be opened, mainly because this project uses session to deliver page prompts,
I don't know much about php session implementation.

OK, close the post. thanks to dream1206 for your suggestion. in one sentence, score 90.
The remaining 10 points are shared. thank you for your enthusiastic help.

In other words, even the bz adults are attracted, not any company can chat online, okay,
You think I don't want to post code ~~ And if I have no brains to post code, would you really want to see it?

OK. thank you for your continued support ~~

Thank you very much for solving the big problem.

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.