Introduction to the working mode of apache

王林
Release: 2020-06-28 17:40:38
forward
3679 people have browsed it

Introduction to the working mode of apache

Apache’s working mode

(Recommended tutorial: apache from entry to proficiency)

prefork work Principle

A separate control process (parent process) is responsible for generating child processes, which are used to listen to requests and respond.

Apache always tries to keep some spare or idle child processes for upcoming requests. In this way, the client does not need to wait for the child process to be generated before getting the service. In Unix systems, the parent process usually runs as root to bind port 80, while the child process generated by Apache usually runs as a low-privileged user.

User and Group directives are used to configure low-privilege users for child processes. The user running the child process must have read permissions on the content he is serving, but must have as few permissions as possible on other resources outside the service content.

How worker works

The number of threads each process can have is fixed. The server will increase or decrease the number of processes based on load.

A separate control process (parent process) is responsible for the establishment of child processes. Each child process can establish a ThreadsPerChild number of service threads and a listening thread, which listens for access requests and passes them to the service thread for processing and response. Apache always tries to maintain a spare or idle pool of service threads.

In this way, the client does not need to wait for a new thread or new process to be established before it can be processed. In Unix, in order to be able to bind port 80, the parent process is usually started as root. Subsequently, Apache creates child processes and threads as users with lower privileges. The User and Group directives are used to configure the permissions of the Apache child process. Although the child process must have read access to the content it provides, it should be given as few privileges as possible.

In addition, unless suexec is used, the permissions configured by these instructions will be inherited by the CGI script.

Event MPM

This is the latest working mode of Apache. It is very similar to the worker mode. The difference is that it solves the problem of keeping-alive long connections. The problem of wasted thread resources. In the event working mode, there will be some special threads used to manage these keep-alive type threads. When a real request comes, the request will be passed to the server thread. After the execution is completed, and allowed it to be released.

This enhances request processing in high concurrency scenarios. The apache2.4 version in unix systems uses this mode.

The above is the detailed content of Introduction to the working mode of apache. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:juejin.im
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template