search
HomePHP FrameworkSwooleWhat are the processes of swoole?

What are the processes of swoole?

Dec 25, 2019 pm 03:35 PM
swoole

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools