Apache Configuration Optimization

Source: Internet
Author: User

Recently participated in a lot of interviews, more or less a little bit of sentiment, it can be said that the concept of a lot of changes, especially as a developer positioning, the original just think that developers just need to write good code on the line, so only need to have data structure, algorithms, design patterns, refactoring knowledge on the line. But after many interviews, realize that the maintenance and optimization of the site is also a necessary quality of developers. Almost all interviewers will ask a question, that is, how to optimize a website, this problem involves many aspects, in fact, the interviewer is to investigate your common server, the knowledge of the database is familiar.

Apache configuration optimizations can be considered in the following ways:

One. Memory

To make the server run fast enough, the point is to make sure that you have enough memory. The method is to determine the average amount of memory required to run the Apache process. Multiply this number by the maximum amount of load.

If, for whatever reason, you cannot add more memory to the server, you can use the same technique to calculate the maximum number of sub-processes that can be serviced at any time, using the Maxclient

directive to limit the maximum number of processes that Apache can handle.

Two. Adjust the setting of the Keep-link (KeepAlive)

The default behavior of HTTP is to request a file on a new connection, which can take a lot of time to start and close the connection. With KeepAlive, you can make multiple requests on a single connection, so

You can reduce the time it takes to establish a socket connection, which in turn speeds up the loading of the client when it requests the content of the page.

KeepAlive on

Maxkeepaliverequests 0

KeepAliveTimeout 15

Three. Avoid DNS queries

DNS queries take a long time, so try to avoid it, and it may take a few minutes for the query to expire if the client's address is not fully queried, and

During this time, the child process that executes the query will not be able to do anything else. method to always set the hostnamelookups directive to off

Four. Best-of-breed symbolic links

If the server is set to not follow symbolic links, Apache must consider the file and whether the directory is a symbolic connection. Then Apache must consider whether the file and directory are symbolic links,

In addition, if option SymLinksIfOwnerMatch is enabled, Apache must not only check whether a particular file is a symbolic link, but also check the link itself and the ownership of the object.

While this enforces some kind of security protection principle, it can take a considerable amount of time. And will reduce the speed of operation. If you focus on performance, use option FollowSymLinks, Apache

Settings do not check for symbolic links.

Five. Minimizing the impact of. htaccess files on performance

Enable allowoverride only in the necessary directories and tell Apache not to waste time looking for. htacess files in a different location

AllowOverride None

Then start the necessary. htacess file with the <Diretory> block

Six. Disable Web content negotiation

If possible, disable Web content negotiation. However, if you must use network negotiation, such as a Web site with multiple languages, you should use the Type-map processor instead of the MultiViews directive.

When using MultiViews to send out requests, Apache needs to get a list of directories.

Disables non-essential web content negotiation. If you really need to negotiate with Web content, use the Type-map processor instead of the MultiViews option

Option-multiviews

AddHandler type-map var

Seven. The creation of the optimization process

The Minspareservers and Maxspareservers directives control the size of the server pool so that there is always a child process waiting for the request to be introduced by the service.

If the number of idle processes is less than minspareservers, Apache will generate a minimum number of processes, and similarly, if the number of idle processes is more than maxspareservers,

Apache will delete the process until it is less than the maximum number.

Eight. Adjust the generation of threads

Principle of the same (vii)

Apache Configuration Optimization

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.