Question: 分析apache2 MPM机制
First:
1. prefork
没有线程
This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server that handles requests in a manner similar to Apache 1.3. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries. It is also the best MPM for isolating each request, so that a problem with a single request will not affect any other.
How it work?
A single control process is responsible for launching child processes which listen for connections and serve them when they arrive. Apache always tries to maintain several spare or idle server processes, which stand ready to serve incoming requests. In this way, clients do not need to wait for a new child processes to be forked before their requests can be served.
父进程 具有ROOT权限去管理权限小的子进程。
父进程在没有REQUEST到来之前就生成几个子进程。
http://httpd.apache.org/docs/2.2/mod/prefork.html
不需要在多个线程间穿梭,省了资源
2. worker
This Multi-Processing Module (MPM) implements a hybrid multi-process multi-threaded server. By using threads to serve requests, it is able to serve a large number of requests with fewer system resources than a process-based server. However, it retains much of the stability of a process-based server by keeping multiple processes available, each with many threads.
http://httpd.apache.org/docs/2.2/mod/worker.html
一个进程多个线程
一个进程可以处理更多的REQUEST, 在大并发量时候有优势