Home >Operation and Maintenance >Apache >What are the features of Apache?
Functional features of Apache
1. Highly modular (Recommended learning: Getting Started with Apache )
Apache supports more functions in the form of modularization. The addition and deletion of different functions can be completed by loading and unloading modules. Similar to the modularization of the Linux kernel, the kernel driver can be loaded and unloaded. module. Constitutes the core modules model;
2. Supports dynamic loading and unloading of modules
is a function similar to hot-swapping, which can realize the service without restarting Situation loads and unloads modules and makes them available.
3. Support multi-channel processing module MPM
Apache can have three (processing) working modes, which are:
prefork- --Multi-process I/O model, one process handles one request, is the default working mode of Apache
In this working mode, there is a main process and multiple sub-processes, and those sub-processes are generated and recycled by the main process. The main process is responsible for generating sockets and managing sub-processes, but is not responsible for processing requests. The main process is executed as root;
The sub-process is the real role responsible for processing requests. There will be multiple idle sub-processes at the beginning. A process waits to handle a request, and a child process handles a request. The child process is executed by the apache user.
worker----Reuse multi-process I/O model
In this working mode, there is a main process, and the main process is also responsible for managing sub-processes Process does not process requests. The main process generates multiple sub-processes, and each sub-process generates multiple threads. One thread handles one request. In this way, assuming that the number of sub-processes is M and the number of threads of each sub-process is N, this working mode M*N requests can be processed concurrently. This mode takes up less memory and is mostly used for large websites.
event-----Event-driven model
event works similarly to worker, both handle M*N requests concurrently. But the improvement made by event is that the threads in each sub-process are divided in more detail, including management threads and service threads. Why is it designed like this?
We know that the HTTP1.1 version defaults to persistent connection keepalive. If a connection is established but no request is sent, the bandwidth of this connection will be occupied until the specified time and will not be released. Therefore, a management process has been added to specifically monitor the keepalive. Type of service thread, when a real request occurs, the management thread transfers the request to the service thread for processing. After the processing is completed, the management thread will release the resources of the service thread. Increased bandwidth utilization.
4. Virtual host
The number of visits to some websites is pitifully low. If a dedicated server is used to build such a low number of visits, it is really not worth it. Therefore, I came up with the idea of building multiple websites on one server. Multiple websites share one server to reduce resource consumption. This function is called the virtual host function.
A server builds multiple websites, each website corresponds to a different domain name. When an external client wants to access, DNS will resolve the domain names of these different websites to the same server, and the server will resolve the domain names of these different websites to the same server according to the header of the HTTP request. The domain name information in the row will forward the request to the corresponding directory resource.
Tips: The difference between a virtual host and a virtual machine->A virtual host is a function of deploying multiple websites on one host. The hosts that support so many websites run the same operating system; A virtual machine is a system that virtualizes multiple hosts through VMware, LVM and other technologies. These virtual hosts can run different operating systems.
5.CGI universal gateway interface
supports dynamic web pages. It will be very obscure to say this. Let’s first talk about what a gateway is. A gateway is the interface through which hosts in two network segments communicate. Hosts in the same network segment do not need to go through the gateway when communicating. However, once hosts in different network segments communicate, To communicate, the data needs to be handed over to the gateway first, and then the gateway can transfer it to another network segment.
Similarly, looking at CGI, the web server can only send static pages. When the server receives a file request such as index.php, the server cannot send index.php.
Because this is a dynamic file, CGI will process index.php into a prescribed data format at this time, and then hand it over to the PHP interpreter for execution, and then the executed data will be processed by CGI, and finally The results are sent from the server to the client. The CGI here serves as the conversion interface between static requests and dynamic requests.
6. Support reverse proxy
7. Can achieve load balancing
8. Support path aliases
In order to prevent users from knowing the real directory of server resources, you can make an alias for the directory. Users only need to know the alias, and the alias will automatically jump to the real directory.
9. Security authentication mechanism can be implemented
The above is the detailed content of What are the features of Apache?. For more information, please follow other related articles on the PHP Chinese website!