This article presents 5 tips for configuring Apache 1.3 or Apache 2.0 servers. We will describe the following configuration scenario: adjust Apache's
Accept ()serialization, Apache 2.0 threads, using
Mod_sslSSL session caching, optimizing keep-alive timeout values, and checking the server load to balance the amount of requests that the server can handle.
Acceptmutex
The Acceptmutex indicator is introduced in Apache 1.3.21 and Apache 2.0, which presents a unique opportunity to tune the performance of the server. This indicator configures the accept () handling of Apache. There is no need to accept blocking on some systems that have only one listener. This is called single Listen unserialized Accept (Slua). However, for those configurations that have multiple listeners or on an operating system that has a thundering herd problem on the receiving system call function (no matter how many listeners), the connection-acceptance program must be serialized.
A certain degree of performance analysis of accept ( covalent ) congestion strategy is performed by the Sander Temme. This report summarizes the strategy of the Apache 1.3.21 in this regard, as follows:
- Irix's Uslock (Uslock)
- POSIX cross process blocking (pthread)
- SystemV semaphores (Sysvsem)
- fcntl () blocking (FCNTL)
- flock () blocking (flock)
- OS/2 semaphores (Os2sem)
- TPF Blocking (Tpfcore)
- None (None)
Although it is possible to use Acceptmutex none , your system may be plagued by thundering herd problems and deadlocks in this configuration. These problems can cause the server to slow down processing and even stop responding. The none option is definitely not available on the actual system. Under the unofficial test, pthread locks should be the best solution. However, pthread blocking across processes is not available to all systems.
With version 2.0 and thread (worker MPM)
One notable improvement of Apache 2.0 is the support thread. Some operating systems, such as Solaris, can significantly improve system performance in the context of threading technology. Other operating systems, such as Linux, may not be significantly improved in performance.
In the case of Apache 2.0, the strategy for processing the request has been theoretical, which is called the MPM: the Multi process model. The older Apache 1.3 model is represented by Prefork MPM, which is the default MPM for 2.0 on UNIX platforms. In this mode, there is a separate process that processes each request. However, if you compile Apache 2.0 with the --with-mpm=worker option, then the server request will be handled by the thread. This approach greatly reduces the load that the operating system handles requests with a well-designed threading implementation scenario.
SSL Session Caching
If you have a mod_ssl supplemental plugin (already included in Apache 2.0) for Apache 1.3 or Apache 2.0, you can use session caching to improve system performance. This improvement can significantly reduce the SSL connection load. There are three ways to set session caching:
- DBM (dbm), which is a common format for storing items on disk (htpasswd can store passwords in dbm format)
- Shared memory loop cache (SHM or SHMCB)
- Shared memory ha (SHMHT)
You need to specify the file path when using the above options. In the case of a dbm variable, the file is written to disk. For shared memory variables, the file will be used as a storage backup of the operating system's preferred shared memory mechanism. It is noteworthy that most operating systems do not allow shared memory segments to be built on drives that are mounted over a network (mount), such as NFS, so the server must be provided with a file path.
We recommend that you use shared memory, but you may use the DBM solution on platforms that do not have shared memory.
For more information and syntax on SSL session caching, see:
KeepAliveTimeout
Suppose a user reads a page on a Web site and then clicks a link to another page in a guide station. If this process occurs within the KeepAliveTimeout cycle (the default is 15 seconds), then you do not have to create a new TCP server connection. This greatly reduces the load on your computer. However, the server cannot handle more requests in this time zone. After the KeepAliveTimeout cycle, the server can process the latest requests from different clients. Therefore, you must increase the number of request processes or threads to meet the need for idle requests. This value should be carefully adjusted to achieve optimal status.
Using Mod_status
Using Mod_status to check the server load, you can get important information for tuning server performance.
The apachectl Status command is a quick way to check the status of a server. If the output of the command does not consistently show the work process that is available. Then it's best to increase the minspareservers or Minsparethreads value (in the case of Apache 2.0 using threaded MPM). You may also need to increase the maxclients value.
For more information about the Mod_status and Apache module Mpm_common, please refer to
Mod_statusAnd
Mpm_common。
Summary
You can use the techniques presented in this article to maximize the performance of the server while maintaining the normal operation of the site.