Let Apache's website be faster

  

The recent friend's server access is too large, causing the page to open slowly, and the download speed has dropped to 30-40KB/sec. Due to funding and environmental issues, the cluster solution has not been applied. With the above factors, I decided to optimize by adding modules to Apache. Here is my implementation process. If you are interested in it, let's take a look. Text: Apache 2.0's performance improvement is most attractive. Support POSIX On a threaded Unix system, Apache can run in a multi-process and multi-threaded mode through different MPMs, enhancing the scalability of some configurations. Compared to Apache 1.3, version 2.0 does a lot of optimization to improve Processing power and scalability, and most improvements will take effect by default. But at compile and run time, 2.0 also has a number of options that can significantly improve performance. MPM (Multi-Processing Modules) is Apache2 The most important feature affecting performance in .0. It is no exaggeration to say that the introduction of MPM is the most important change of Apache 2.0. Home knows that Apache is based on a modular design, and Apache 2.0 extends the most basic functionality of modular design to a Web server. The server is loaded with a multi-processing module that binds the local network port, accepts requests, and Scheduling child processes to handle requests. Extending modular design has two important benefits: ◆ Apache can support multiple operating systems more concisely and efficiently; ◆ Servers can be customized to the specific needs of the site. At the user level, MPM looks It is very similar to other Apache modules. The main difference is that only one MPM can be loaded into the server at any time. Let's use Linux RedHat AS3 as a platform to demonstrate how to specify MPM in Apache 2.0. # wget http://archive. Apache.org/dist/httpd/httpd-2.0.52.tar.bz2 # tar jxvf httpd-2.0.52.tar.bz2 # cd httpd-2.0.52 # ./configure --help| Grep mpm is shown below: --with-mpm=MPM Choose the process model for Apache to use. MPM={beos| Worker| Prefork| Mpmt_os2|  Perchild| Leader| Threadpool} The above operation is used to select the process model to be used, ie which MPM module. Beos and mpmt_os2 are the default MPMs on BeOS and OS/2 respectively. Perchild is mainly designed to run as different users and groups. Different subprocesses. This is especially useful when running multiple virtual hosts that require CGI. It will do better than the SuExec mechanism in version 1.3. Both leader and threadpool are based on worker variants, and are still in an experimental phase, some In some cases, it does not work as expected, so Apache officially does not recommend it. Therefore, we mainly explain the two product-level MPMs with the highest performance relationship between prefork and worker. Prefork works if not used. --with-mpm” Explicitly specify a certain MPM, prefork is the default MPM on Unix platform. The pre-derived child process used by it is also the mode adopted in Apache 1.3. Prefork itself does not use threads, version 2.0 It is used to maintain compatibility with version 1.3; on the other hand, prefork uses a separate subprocess to handle different requests, and the processes are independent of each other, which makes it the most stable MP. M. Prefork works by controlling the process to create a process in order to meet the needs of MinSpareServers after initial establishment of the "StartServers" process. Wait for one second, continue to create two, wait another second, continue Create four …… so increase the number of processes created exponentially, up to 32 per second, until the value set by MinSpareServers is met. This is the origin of pre-pref. This mode does not have to come in the request When new processes are spawned, system overhead is reduced to increase performance. Workers work in comparison to prefork, which is a new MPM that supports multi-threading and multi-process hybrid models in version 2.0. Because of the use of threads, Can handle relatively large requests, and system resources are less expensive than process-based servers. However, workers also use multiple processes, each process generates multiple threads to obtain process-based server stability. This MPM The way of working will be the development trend of Apache 2.0. The working principle of the worker is that it is generated by the main control process “StartServe Rs & rdquo; a child process, each child process contains a fixed number of ThreadsPerChild threads, each thread handles the request independently. Similarly, in order not to generate threads when the request comes, MinSpareThreads and MaxSpareThreads set the minimum and maximum number of idle threads; and MaxClients settings The total number of threads in all child processes. If the total number of threads in the existing child process cannot satisfy the load, the control process will spawn the new child process.

Copyright © Windows knowledge All Rights Reserved