Apache's working mode
1.apache Three modes of Operation
we all know that Apache has three types of work modules, prefork, worker, event, respectively.
prefork: Multi-process , each request with a process response, this process will use the Select mechanism to notify.
Worker: Multi-threaded , a process can generate multiple threads, each thread responds to a request, but the notification mechanism is select but can accept more requests.
Event : Based on the asynchronous I/O model , a process or thread, each process or thread responds to multiple user requests, and is implemented based on the event-driven (that is, the epoll mechanism).
How the 2.prefork works
If you do not explicitly specify a mpm,prefork with "--with-mpm", it is the default MPM on the UNIX platform. The pre-derived subprocess that it uses is also the pattern used in Apache1.3. Prefork itself is not used to threads, Version 2.0 is used to maintain compatibility with version 1.3, and on the other hand, prefork processes different requests with separate sub-processes, and the process is independent of each other, making it one of the most stable mpm.
How the 3.worker works
compared to Prefork,worker is the new MPM in version 2.0 that supports multi-threaded and multi-process hybrid models. Because of the use of threads for processing, you can handle a relatively large number of requests, while system resources are less expensive than process-based servers. However, the worker also uses multiple processes, Each process generates multiple threads to obtain stability based on the process server. This mpm's way of working will be the trend of Apache2.0 development.
4.event feature based on event mechanism
a process responds to multiple user requests, uses the callback mechanism to make the socket reusable, requests that the process does not process the request, but directly to other mechanisms, through the epoll mechanism to inform whether the request is complete, and in this process, the process itself has been idle, You can always receive user requests. A process can be implemented to respond to multiple user requests. Supports a large number of concurrent connections and consumes less resources.
Apache's working mode