httpd operating mode of MPM

httpd operating mode of MPM

MPM (Multi -Processing Modules) multiprocessing mode module

prefork: multi-process I / O model, each process in response to a request, the default model

Pre-derivative mode, a master control process, and then generates a plurality of sub-processes, each sub-process has an independent thread in response to a user request, the memory occupied by relatively, but is relatively stable, it can be a minimum and maximum number of processes, the oldest a model, is also the most stable mode for traffic is not a big scene

Features:

  • A main process: recycling and generating n sub-process, creates a socket, does not respond to the request
  • A plurality of sub-processes: work processes work, each child process a request process; the initial system, the process generated in advance a plurality of idle, waiting for a request, the maximum does not exceed 1024

Benefits: stable
Disadvantages: slow, resource intensive, not suitable for high concurrency scenarios

worker: multiplexed multi-process I / O model, multi-process multi-threaded, IIS uses this model

mark

Is a multi-process and multi-threaded hybrid model, there is a control process to start multiple sub-processes, each child process which contains a fixed thread, use the thread to handle the request process, when the thread is not used will launch a new one the child process, and then start processing the request thread inside the process, because of its use of threading request, it can withstand higher concurrency.

Features:

A main process: generating m child processes, each process is responsible for the birth of a child n threads, each thread in response to a request, and transmits a response request:

m x n


Advantages: Compared prefork less memory occupied, can handle more requests simultaneously

Disadvantages: long connection keep-alive, and will always be occupied by a thread, even if no data transmission, also need to wait until the timeout will not be released. If too many threads, are so occupied, it can lead to no service threads at high concurrency scenarios available. (The problem in prefork mode, the same will happen)

event: event-driven model (model variants worker)

Apache in the latest models, are event-driven model (epoll), each process in response to multiple requests, now has a stable version available modes. It is much like the pattern and worker, the biggest difference is that it solves the next keep-alive scenario, the waste of resources issues have long been occupied by a thread (because some threads are keep-alive, hanging in the air where waiting, middle little request over, even wait for a timeout). event MPM, there will be a dedicated thread to manage the keep-alive type of thread, when there is a real request over the request to the server thread, after the implementation, but also allow it to be released. This enhances the request processing capability at high concurrency scenarios

event only when there is data transmission began to establish a connection, the connection request will trigger a worker thread, which uses a TCP option, called the delay accepting connections TCP_DEFER_ACCEPT, add this option, only if the client TCP connection, Do not send the request, it will not trigger Accept operation, it will not trigger the worker to work, a simple anti-attack (TCP connection

mark

Features:

A main process: generating m child processes, each process is responsible for the birth of a child n threads, each thread in response to a request, and transmits the response request: m * n, a dedicated monitor thread to manage the keep-alive type of thread, when there is a real request, the request is passed to the service thread, after the implementation, but also allowed the release. This enhances the request processing capability at high concurrency scenarios


Advantages: single-threaded respond to multiple requests, takes up less memory, high concurrency under better performance, there will be a dedicated thread to manage the keep-alive type of thread, when there is a request to come true, and passes the request to the server thread after finished, and allow it to release

Cons: no thread-safe control

There are real requests over time, it passes the request to the server thread, after the implementation, but also allows it to release

Cons: no thread-safe control

Published 62 original articles · won praise 7 · views 1267

Guess you like

Origin blog.csdn.net/qq_36801585/article/details/104452273
Recommended