Prefork mode
This multi-path processing module (MPM) implements a non-threaded, pre-derived Web server that works in a similar way to Apache 1.3. It is suitable for systems that do not have a thread-safe library and need to avoid threading compatibility issues. It is the best mpm to require each request to be independent of each other, so that if a request has a problem it will not affect the other request.
This MPM has a strong self-tuning capability and requires very little adjustment of the configuration instructions. The most important thing is to set the maxclients to a value that is large enough to handle the potential request spikes, and not too large to use more memory than the size of the physical memory.
Worker mode
This multi-path processing module (MPM) enables a network server to support mixed multithreaded multi-process. Because a thread is used to process requests, a large amount of requests can be processed, while the overhead of system resources is less than the process-based MPM. However, it also uses a multi-process, with each process having multiple threads to obtain the stability of the process-based MPM.
The most important instructions for controlling this mpm are the Threadsperchild instructions that control the number of threads allowed to be established by each subprocess, and the maxclients instruction that controls the number of buses allowed to be established.
In terms of definition, the worker pattern is significantly better than prefork at PV traffic, but in fact this is not the case, the following PHP official documentation
PHP is just a binder. He put a lot of third-party module libraries together, and then provide users with a visual understanding of the unified language interface, let us feel that they are a whole. PHP is easy to use and powerful to rely on a stable and powerful running platform. He needs an operating system, a Web server, and a third-party module library to fuse together. Any one of them hangs up and PHP needs to find the problem quickly and solve it in various ways. If we were to run PHP with a Web server that did not fully isolate the running thread, did not completely isolate the memory space, and did not have a powerful container to record each requirement, PHP would become prone to problems.
If we want to use a multithreaded multi-process module, we can look at the PHP fastcgi configuration. In fastcgi mode, PHP runs in its own memory space.
Official text:
php is glue. It is the glue used to build cool Web applications by sticking dozens of 3rd-party libraries together and making it all AP Pear as one coherent entity through an intuitive and easy to learn language interface. The flexibility and power of PHP relies on the stability and robustness of the underlying platform. It needs a working OS, a working Web server and working 3rd-party libraries to glue together. When any of these stop working PHP needs ways to identify the problems and fix them quickly. When you make the underlying framework more complex by does have completely separate execution threads, completely separa Te memory segments and a strong sandbox for each request to play in, further weaknesses is introduced into PHP ' s system.< /p>
Two modes of operation for Apache Prefork and worker