In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about the differences between workerman and swoole. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Differences: 1, swoole is a socket communication framework implemented in C language, while workerman is a socket framework implemented in pure php; 2, socket in workerman is responsible for by the worker process, and swoole is responsible for by the reactor thread in the main process.
Operating environment of this tutorial: Windows10 system, Swoole4 version, DELL G3 computer
What are the differences between workerman and swoole
Workerman and swoole are very controversial at this stage. You have to get to know each other sometime, or you won't be in the php circle. Swoole is a socket communication framework implemented in C language, while workerman is a socket framework implemented in pure php. There are also many differences between the two process models.
Master process
This process is more complex, and I think the core process, this is a multi-threaded process, respectively, a main thread and n reactor threads (the number can be configured).
The main thread is used for accept new connections, then evaluates the number of connections that each reactor thread is responsible for maintaining, and then assigns it to the least number of reactor threads to ensure that the load of each reactor thread is balanced.
In essence, once an socket is readable or writable, it is sent by the reactor thread to the worker process or to the client. In addition, the main thread is also responsible for taking over all signals to avoid interruptions when the reactor thread receives the signal.
To put it in a foreign way, the master process is responsible for the connection's accept, hosting, and the readability and writeability of socket (sending and receiving data). In essence, the master process is responsible for IO. It is also important to note that reactor threads work in a completely asynchronous and non-blocking manner.
Manager process
The manager process is the mother of the worker process and the taskworker process, which means that the manager process fork gives birth to the worker process and the taskworker process, so the manager process is responsible for the maintenance obligations of the worker process and the taskworker process, including monitoring their status, pulling a new process after they accidentally hang up (avoiding the zombie process), and smoothly restarting (the legendary reload).
Worker process
The worker process is fork from the manager process. To put it bluntly, this process is to move bricks to work (the business code repeatedly mentioned in the official document). In fact, it is the curd business logic code of the usual code, okay? It's just that the worker process compares diao with the fact that it can work asynchronously or synchronously. If you don't understand what it means, recite it first and mix your face first.
Taskworker process
The taskworker process (later called the tasker process) is essentially a worker process, but a special worker process. If there are some time-consuming operations in your worker process, you can throw it to the tasker process first, do something else yourself, and wait for the tasker to finish, and then get it back by the worker process, which is very diao. But the tasker process can only work synchronously, not asynchronously. This is why tasker processes cannot use timers, while worker processes can use timers.
Briefly summarize and mix together to talk about how these processes work together. In other words, the master process is the sales of the work, but the specific work is done by the worker process. If the worker process feels that some processes are too busy and complex, it can be done by the tasker process. The manager process is the human resources guarantee department of the logistics worker process and the takser process, which is responsible for their life and death and eating and drinking.
Workerman
The process model of workerman is relatively simple. First of all, compared with swoole, workerman does not have reator threads in swoole, and secondly, workerman does not have worker processes and tasker processes used to deal with ordinary business. In the case of workerman, the socket is the responsibility of the worker process, while in swoole, the reactor thread in the main process is responsible. After receiving the data, swoole can handle the business through its own worker process (somewhat similar to the fpm process).
Workerman is a high-performance PHP socket server framework. Workerman is based on PHP multi-processes and libevent event polling library. PHP developers can develop their own network applications as long as they implement one or two interfaces, such as Rpc services, chat room servers, mobile game servers and so on.
The goal of workerman is to make it easier for PHP developers to develop high-performance socket-based applications without knowing the details of PHP socket and PHP multi-processes. Workerman itself is a PHP multiprocess server framework with modules for PHP process management and socket communication, so it can run independently without relying on containers such as php-fpm, nginx or apache.
Thank you for reading! This is the end of the article on "what are the differences between workerman and swoole". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.