High concurrency, Apache reboots frequently

Source: Internet
Author: User
Tags apache error log
There are several servers that are windows2008 systems.
I configured the maximum concurrency per server for Apache, which is Threadsperchild 1000
These days in order to optimize the original program, you need to write a multi-threaded (PHP with Apache multi-threaded implementation) of the long-running program, the number of threads is 50.
Found that these long-running programs up to 1 hours will be unified stop, looking for a half-day reason to find that when the program stops Apache error log will have "child process exited with status 255-restarting." Information, and then Apache restarts automatically.
So I checked the Apache error log on each server, and found that the higher the concurrency of the server, the more frequent the Apache restart frequency, there is a concurrent server in the 200 or so every few minutes to restart.
Later I tried to use a thread to execute that long running program, found that 1 days down no problem, and then change 50 threads of 1 hours and stopped.
Hey, I have been messy, to Apache is not enough to understand, Apache configuration is set up a multi-port and concurrency number, the others are original, is there some important configuration I ignored?
On the Internet for a period of time, there is no suitable solution, you can discuss together.
"Child process exited with status 255--restarting." How does the Apache restart problem work?
How does PHP automatically recover when it encounters an Apache automatic restart during a long time execution?


Reply to discussion (solution)

You change this to see, httpd.conf file, I think the general bottleneck is on MySQL. If not yet, decisive change nginx, I was this time ago, now with Nginx, very happy.

 
  
   
      Startservers           5    minspareservers        5    maxspareservers            serverlimit    MaxClients    maxrequestsperchild    1000
 
  

Child process exited with status 255--Restarting
Exit status of the child process 255?? Restart

PHP in Windows is not thread-capable

If you are simulating via fsockopen, that is the unsolicited HTTP process. For Apache, this is no different from browser-initiated
When concurrent HTTP requests exceed the number of Apache-preset concurrency, only queuing occurs, not crashes
Of course, the concurrency number is guaranteed by memory. The memory is not enough, the crash is natural

In addition, if the HTTP responder does not output for an extended period of time, Apache will suspend it. It's not the Apache problem, it's the problem with the program.

You change this to see, httpd.conf file, I think the general bottleneck is on MySQL. If not yet, decisive change nginx, I was this time ago, now with Nginx, very happy.


Thank you, I didn't use Nginx, now I decided to try.

Not to notice that you are a Windows system, maybe the moderator said that right.

Child process exited with status 255--Restarting
Exit status of the child process 255?? Restart

PHP in Windows is not thread-capable

If you are simulating via fsockopen, that is the unsolicited HTTP process. For Apache, this is no different from browser-initiated
When concurrent HTTP requests exceed the number of Apache-preset concurrency, only queuing occurs, not crashes
Of course, the concurrency number is guaranteed by memory. The memory is not enough, the crash is natural

In addition, if the HTTP responder does not output for an extended period of time, Apache will suspend it. It's not the Apache problem, it's the problem with the program.


I did it through fsockopen simulations.
I've been monitoring it for a while. When an Apache error occurs, the memory in the Task manager is not high enough to be caused by insufficient memory.
I also look at the online said to output, so I also output the following
echo ';//A Space ob_flush (); flush ();

The output is written, right? Output buffer content flush These two sentences do not know whether to add, my theoretical foundation is not good, just think the output has been placed in the buffer will have problems, please correct.

Not to notice that you are a Windows system, maybe the moderator said that right.


There seems to be a Windows version, in short I look first.
Really not only the overall change of Linux, is the corresponding need to modify the project is a bit more.

PHP runs under Linux. There is basically no need to change much. Note that the corresponding file is case-sensitive.

If it is under Windows, it is recommended to use Fsockopen to simulate the run.

Don't think more Linux this time can continue to use Apache or nginx even if you now temporarily solve the problem of win next pit continues to wait for you.

A pit and then a pit, too cruel ...
But also indeed with the system more and more, trouble is more and more, only for the previous experience left behind the hidden trouble to pay.
Yesterday thought of a temporary solution, wrote a monitoring program to monitor multi-threaded operation, once a long time does not operate to start multi-threaded (long-running program is now observed as if it is not very likely to stop itself, basically is the Apache restart caused, so then he restarted that is).
Today I observed a bit of stability, and finally relaxed.
Next I will try to use the simplest program, test the Apache concurrency when the recurrence of the phenomenon, the problem first qualitative, and then decide whether to solve the program problem or change the environment.

The confirmation should be the Apache problem.
Windows Nginx has a problem, when an access is not finished, other access can not be executed, but I have to write a long time to execute the program.
Environmental problems will not be able to, it seems that the biggest hope is to Linux, even if it is a pit.
Thank you all, first knot paste.

  • 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.