Apache High Load Performance tuning

Source: Internet
Author: User

1 read the Apache configuration optimization recommendations below, then adjust the relevant parameters to observe the status of the server.2 Apache Configuration Tuning Recommendations:3Enter/usr/local/apache2/conf/under the extra directory4 Apache optimization,5 after the above operation, Apache has been able to run properly. However, for sites with a slightly larger number of accesses, the Apache default configuration is not sufficient, we still need to adjust some of the Apache parameters, so that Apache can perform better performance in a large traffic environment. Below we describe some of the parameters that have a significant performance impact in the Apache configuration file httpd.conf. 6 7(1Timeout This parameter specifies the maximum wait time (in seconds) before Apache receives a request or sends the requested content, and if it exceeds that time, Apache discards the request and releases the connection. The default value for this parameter is 120, the recommended setting is 60, and for sites with a large amount of traffic you can set to 30 or 15. 8 9(2) KeepAlive This parameter controls whether Apache allows multiple requests in a connection, which is turned on by default. However, for most forum type sites, it is usually set to off to turn off this support. Ten  One(3) MPM-prefork.c By default, Apache uses the prefork (process) mode of operation, which can be said to be the core and key to the Apache performance impact of this part of the parameter setting. The user can find the following configuration section in the Configuration document: A     -Startservers5 -Minspareservers5 theMaxspareserversTen -MaxClients the -Maxrequestsperchild0 -     + Copy Code - This is the configuration section that controls the Apache process, and in order to better understand the parameters in the above configuration, let's look at how Apache controls the process. We know that in Unix systems, many services (service) daemons (Daemon) Create a process at startup to prepare for a possible connection request, and the service enters the port listening state when a request from the client is sent to the port that the service listens on. The service process processes the request, and during processing, the process is in an exclusive state, meaning that if there are other requests arriving at this time, the requests can only "queue" for the current request to be processed and the service process to be freed. This leads to more and more requests waiting in the queue, and the actual performance is that the service is very poorly handled. Apache uses the Prefork model to solve this problem very well. Let's look at how Apache is actually working efficiently.  +  AWhen Apache starts, Apache will start startspareservers idle processes and prepare to receive processing requests, and when multiple requests arrive, Starspareservers will be reduced, When the idle process is reduced to minspareservers, Apache is able to continue to have sufficient process processing requests, it will start the startsservers process backup, which greatly reduces the request queue waiting, so that the service efficiency increased, That's why it's called pre-.the reason for the fork; Let's continue to follow Apache's work, we assume that Apache has started 200 processes to process requests, in theory, Apache has 205 processes at this time, and after a while, Assuming that 100 requests have been answered and processed by Apache, then the 100 processes are freed up as idle processes, so Apache has 105 idle processes at this time. For a service, it doesn't make sense to start too many idle processes, but it slows down the overall performance of the server, so does Apache really have 105 idle processes? Of course not! In fact, Apache is checking itself at any time, and when it finds that there are more than maxspareservers idle processes, it automatically stops shutting down some processes to ensure that the idle process is too much. Speaking of which, users should have a certain understanding of how Apache works, and if you want more detailed instructions please refer to the Apache manual documentation.  at  - We also have two parameters not described: MaxClients and maxrequestperchild;maxclients Specify the maximum number of clients that Apache can connect to at the same time, if more than maxclients connections are allowed, The client will get a "server Busy" error page. We see that by default maxclients is set to 15, which is obviously not enough for some medium-sized sites and large sites! Maybe you need to allow 512 client connections to meet your application needs, okay, so let's change the maxclients to 512. Save httpd.conf and exit, restart Apache, unfortunately, during the restart process you see some error prompts, Apache restart failed. The error message tells you that maxclients can only be set to 256, I believe you must be very disappointed. But don't be depressed, Apache as a world-class Web server must not be so thin! By default, maxclients can only be set to no more than 256 integers, but if you need to be completely customizable, then you need to use the Serverlimit parameter to use, simply say serverlimit is like a bucket, While maxclients is like water, you can accommodate more water (maxclients) by replacing a larger bucket (set Serverlimit to a larger value), but be aware that The set value of maxclients is not greater than the set value of Serverlimit!  -  -Note: Maxclents <Serverlimit -  - let's look at the Maxrequestperchild parameter, which specifies how many threads in a connection process can work at the same time. Perhaps this explanation is too professional, then you just think "network Ant", "Internet Express FlashGet" in the "multi-point simultaneous download" Can, this parameter is actually limit can use a few "point". The default setting is 0, which is: No limit. However, it is important to note that if you set this value too small it will cause access problems, if there is no special need or the traffic pressure is not very large can maintain the default value, if the traffic is very large, it is recommended to set to 2048.  in  - well, explaining so much, let's look at the recommended configuration for the modified PERFORK.C configuration section: to     +Startservers5 -Minspareservers5 theMaxspareserversTen *Serverlimit1024x768 $MaxClients768Panax NotoginsengMaxrequestsperchild0 -     the Copy Code +Having completed the above adjustments to Apache, Apache has achieved significant performance improvements

Apache High Load Performance tuning

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.