Home >PHP Framework >Workerman >What is a worker?

What is a worker?

(*-*)浩
(*-*)浩Original
2019-12-02 09:09:163909browse

What is a worker?

workerman is a high-performance PHP socket server framework. Workerman is based on PHP multi-process and libevent event polling library. PHP developers only need to implement one With two interfaces, you can develop your own network applications, such as Rpc services, chat room servers, mobile game servers, etc.

workerman's goal is to make it easier for PHP developers to develop high-performance socket-based application services without having to understand the details of PHP sockets and PHP multi-processes. (Recommended learning: workerman tutorial)

workerman itself is a PHP multi-process server framework, with PHP process management and socket communication modules, so it does not rely on php- Containers such as fpm, nginx or apache can run independently.

PHP process management: similar to the process management of the operating system.

socket: Two programs on the network exchange data through a two-way communication connection. One end of this connection is called a socket.

Several major features of wokerman:

Pure PHP development

workerman is completely developed using PHP, and uses workerman to develop applications The program can run independently without relying on containers such as php-fpm, apache, and nginx. This makes it very convenient for PHP developers to develop, deploy, and debug applications.

Support PHP multi-process

In order to give full play to the performance of the server's multi-CPU, Workerman supports multi-process and multi-tasking by default. Workerman starts a main process and multiple sub-processes to provide external services. The main process is responsible for monitoring the exit signals of the sub-processes and generating new sub-processes to handle services. This not only improves the performance of the application, but also makes Workerman more stable.

Support TCP, UDP

workerman supports TCP and UDP two transport layer protocols. You only need to change one field of the configuration to change the transport layer protocol and business code. No changes are required.

Support long connections

Many times it is necessary for PHP applications to maintain long connections with clients, such as chat rooms, games, etc., but traditional PHP containers (apache, nginx, php-fpm) it is difficult to do this. Workerman makes it easy to use PHP long connections. A single PHP process can support thousands or even tens of thousands of concurrent connections, and multiple processes can support hundreds of thousands or even millions of concurrent connections.

Support various application layer protocols

The interface supports various application layer protocols, including custom protocols. The protocols supported by Workerman by default include HTTP, WebSocket, and the simple Text protocol. At the same time, Workerman provides a common protocol interface, and developers can easily develop their own protocols based on this interface.

Support high concurrency

workerman supports Libevent event polling library (Libevent extension needs to be installed). Using Libevent has excellent performance in high concurrency. If Libevent is not installed, Use PHP's built-in Select related system calls. cn_notebook where cn_note_id = "";

The above is the detailed content of What is a worker?. 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