Home > php教程 > PHP开发 > body text

Apache performance optimization (3)

黄舟
Release: 2016-12-21 11:25:00
Original
1049 people have browsed it

The following discusses several important modules that are not installed by default. . (Except prefork)

Commonly used modules:

Probably the most commonly used ones are the front-end of PHP and JAVA application servers, which we don’t need in our current application. In addition, in terms of performance, using mod_gzip can reduce traffic by about 40% and reduce the load on the machine for transmission. It is recommended to use it. The files we use are relatively small, so we can see if the time overhead of the compression algorithm and the reduction of the transmission load are cost-effective. Mod_expires can reduce repeated requests by about 10%, allowing repeated users to cache the results of specified page requests locally without making requests to the server at all. But we are using a memory file system, so cache optimization can be completely ignored.

WEB acceleration based on reverse proxy:

Both squid and mod_proxy can achieve reverse proxy acceleration. The cache-based proxy acceleration will be orders of magnitude faster than the original WEB service. The same memory file system is not required.

Key indicators MPM that affect performance:

MPM (Multi-Processing Modules, multi-processing modules). MPM looks very similar to other Apache modules. Unlike other types of modules, Apache must have one and only one MPM running. . The method of specifying MPM

$ ./configure --help|grep mpm

is displayed as follows:

--with-mpm=MPM

Choose the process model for Apache to use.

MPM={beos|worker| prefork|mpmt_os2| perchild|leader|threadpool}

Beos and mpmt_os2 are the default MPMs on BeOS and OS/2 respectively. The main design purpose of perchild is to run different child processes as different users and groups. This is particularly useful when running multiple virtual hosts that require CGI, and will do a better job than the SuExec mechanism in version 1.3. Both leader and threadpool are worker-based variants and are still in the experimental stage. In some cases, they do not work as expected, so Apache officials do not recommend their use. Therefore, we mainly elaborate on prefork and worker, the two product-level MPMs that have the greatest relationship with performance.

If you do not explicitly specify a certain MPM with "--with-mpm", prefork is the default MPM on the Unix platform.

prefork itself does not use threads. Version 2.0 uses it to maintain compatibility with version 1.3; prefork uses separate sub-processes to handle different requests, and the processes are independent of each other, which also makes it the most stable One of the MPM.

The working principle of prefork is that after the control process initially establishes the "StartServers" sub-process, it creates a process to meet the needs of the MinSpareServers setting, waits for one second, continues to create two, waits for another second, and continues to create four ...In this way, the number of processes created is increased exponentially, up to 32 per second, until the value set by MinSpareServers is met. This is where prefork comes in. This mode eliminates the need to create new processes when requests arrive, thereby reducing system overhead and increasing performance.

The above is the content of Apache performance optimization (3). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template