Apache Optimization Configuration 10 recommendations

Source: Internet
Author: User
Tags lstat sendfile

Before the VPS used is the default Apache configuration, feel OK, but with the increase in the number of blog, it is obvious that this configuration can not meet the demand; The following are some of the optimization configuration recommendations in the official Apache manual, which is helpful for the operation efficiency of Apache servers.

  1. Controls the settings of the maxclients to prevent the server from generating too many sub-processes and swapping.
    The data exchange between processes consumes a lot of memory, and the lag caused by data exchange makes the user feel "not fast enough", so the user may go to "stop" and "refresh", resulting in a greater load. It is generally recommended that small sites set maxclients to 12~24.
  2. Choose better hardware, CPU, memory, hard disk, etc.
    This sentence is very chicken, if there are more silver, who would not want to change better? ^_^
  3. Update the operating system regularly and make system patches; If your operating system supports Sendfile () system calls, be sure to install a version or patch with this feature
    In systems that support Sendfile, Apache2 can send static content more quickly and consume less CPU time.
  4. Hostnamelookups set to Off
    Minimize the number of DNS queries. If you use any allow from domain or Deny from domain directives (that is, domain uses a hostname instead of an IP address), the cost is two DNS queries (one forward and one reverse to confirm that there is no fraud). Therefore, in order to get the highest performance, you should avoid using these instructions (using the IP address is also possible without the domain name).
  5. Add FollowSymLinks to your directory
    If you do not use the Options followsymlinks in your site space, Apache must perform additional system calls to verify the symbolic connection. For example: When requesting "/index.html", Apache will execute Lstat () calls to "/www", "/www/htdocs", "/www/htdocs/index.html". and the execution result of Lstat () is not cached, so it is executed once for each request.
  6. Set AllowOverride to None
    It may be inconvenient for a friend to use a virtual host, which will invalidate the settings in the. htaccess, and if necessary, write the rewrite rule directly in the Conf configuration file if required.
  7. Disable content Negotiation
    Although in practice, the benefits of content negotiation outweigh the loss of performance, you can prohibit the use of content negotiation if you are concerned about a bit of performance loss. However, there is still a way to increase the speed of the server, that is, do not use wildcard characters.
  8. Maxrequestsperchild set to non-0 to prevent memory leaks
    The maxrequestsperchild is used to control when the Apache child process is destroyed, the default is 0, which means that the child process will never be destroyed, which may present a risk of a memory leak, with a recommended setting of 10000
  9. KeepAlive and KeepAliveTimeout
    If you are using the Make Mpm_prefork mode (apache default installation), then it is recommended that you set keepalive to OFF, because KeepAlive will establish a connection for each client, Prefork will not create a thread, Estimated 100 users to visit your site at the same time, Apache will hang up ~, if you really want to open, then please set the keepalivetimeout time shorter, such as 5, the default is 60 seconds
  10. Do not statically compile Apache
    Although there will be a lot of people and you say the benefits of static compilation, at the same time, you want to compile one yourself, to experience fun ~ However, the module has been statically compiled into Apache is definitely not a good choice, especially for the lack of money stationmaster, an improper configuration, Apache will take up all of your memory at startup and finally drag down the server ~

Comments

Oh, man! Writing:

I have been using the Apache worker mode, so it doesn't matter if the load is higher. However, it is necessary to set Maxrequestsperchild to non-0, and to avoid leaking memory-causing problems, keepalive is also a parameter to compare. What the bloggers are saying is right!

Freemouse writing:

The worker pattern benefits a lot, but for small traffic sites, there's no need to worry too much.

Excerpt from: http://www.cnphp.info/10-tips-for-optimize-Apache-options.html

Apache Optimization Configuration 10 recommendations

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.