The timeout misunderstanding about Apache

Source: Internet
Author: User
Recently, the number of threads that often Apache on the Web server runs to MaxClients (500), which affects the normal service. Normally, the number of Apache threads does not exceed 100, but it runs to 500, so it must be because some requests to execute scripts are too long. The Apache Logformat (reference http://mylinux.5d6d.com/thread-936-1-1.html) is then set to track how much time is required for some requests. There are individual requests for up to 60s or longer. These visits are certainly problematic and cannot keep them occupied with Apache resources, so think of setting the timeout and disconnect the request if the request does not complete within the specified time. Although this is not very humane, but for the sake of the overall to sacrifice some users.


At first, because the timeout parameters are not well understood, it is felt that setting the timeout parameters in the Apache httpd.conf will limit the time long request. But the practice proved that it was wrong. After checking the data, it was found that in the official document, the timeout of Apache was interpreted as follows:
The TIMEOUT directive currently defines the amount of time Apache would wait for three things:
? The total amount of it takes to receive a GET request.
? The amount of time between receipt of TCP packets on a POST or put request.
? The amount of time between ACKs on transmissions of TCP packets in responses
Probably means:
1. Total time spent receiving a GET request
2. The interval at which TCP packets are sent to the server when post or put requests (not the sum of the intervals)
3. The interval at which TCP packets are sent when the response is sent (not the sum of the intervals)
Here we are more concerned about the 3rd.
In other words, even if the timeout set 1s, the server processing request time can be more than 1s, as long as the server every no more than 1s time to send a little data to the client.
Now think about it, the server and client interaction is not coherent, need
Connect communication----------------------------continuous So repeatedly


So we timeout the parameters limit this interval, not the total time of the communication, so that even if some requests exceed the timeout value, there is still no disconnect.
And my question remains, how to solve it. Because of the PHP program running on the Web server, it is thought to be limited by the configuration of PHP. This involves the max_execution_time in the php.ini.


The default installation of the apache2.0.59, the normal use of a little problem does not. Two days ago bored with SSS scan, the results scan to HTTP that paragraph, suddenly found IE can't open the page ... On the server through the netstat look, there are a lot of my local to the server 80-Port link, the server at this time the state is very normal, cpu/ping delay is not high, but is the browser can not open the page.
Timeout 15
KeepAlive on
Maxkeepaliverequests 500
KeepAliveTimeout 15




See the following default of these four parameters, found
timeout=300
maxkeepaliverequests=100




Suspicion is the problem, will he change to the above settings, scan again, sure enough to open the page normal.


explanation of timeout and keepalivetimeout in Apache configuration (to be continued) http://hi.baidu.com/bmrs/blog/item/1dbf79fff24cd33b5c6008db.html





Zh-cn→zh Apache Configuration

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.