Home > Article > PHP Framework > What are the processes of swoole?
The so-called process is actually a running program in the operating system. For a process, its core content is divided into two parts. One is its memory, and this memory is This process is allocated from the system when it is created, and all the variables it creates will be stored in this memory environment.
Processes in swoole:
1. Master process: main process
2. Manger process: management process
3 , Worker process: working process
4. Task process: asynchronous task working process
Introduction to several processes:
1. Master process
This is The main process of swoole. This process is driven by the core events of swoole. In this process, you can see that it has a MainReactor [thread] and several Reactor [threads]. All swoole's event monitoring will be in these Implemented in threads, such as connections from clients, signal processing, etc.
2. Management Process Manager
To achieve the best performance, Swoole must create multiple worker processes to help process tasks, but the Worker process must fork the operation, but the fork operation is unsafe. Yes, if there is no management, many zombie processes will appear, which will affect server performance. At the same time, the worker process will be accidentally killed or exit abnormally due to program reasons. In order to ensure the stability of the service, the worker process needs to be re-created.
Swoole will create a separate management process during operation, and all worker processes and task processes are forked from the management process. The management process will monitor the exit events of all child processes. When a fatal error occurs in the worker process or the running life cycle ends, the management process will recycle the process and create a new process.
3. Worker process
The worker process belongs to the main logical process of swoole. The user processes a series of requests from the client, accepts the request packet delivered by the Reactor thread, and executes the PHP callback function to process the data. The response data is generated and sent to the Reactor thread. The Reactor thread sends it to the TCP client in either asynchronous non-blocking mode or synchronous blocking mode
4. Task process
taskWorker process Cheng is an asynchronous worker process provided by swoole. These processes are mainly used to process some long-term synchronization tasks and deliver them in the worker process.
PHP Chinese website has a large number of free Swoole introductory tutorials, everyone is welcome to learn!
The above is the detailed content of What are the processes of swoole?. For more information, please follow other related articles on the PHP Chinese website!