Home  >  Article  >  PHP Framework  >  How Swoole handles high concurrency

How Swoole handles high concurrency

(*-*)浩
(*-*)浩Original
2019-12-07 13:32:032922browse

How Swoole handles high concurrency

## Swoole How to deal with high and merged

##① Reactor Model Introduction (Recommended Learning: ## SWOOLE Video Tutorial )IO multiplexing asynchronous non-blocking program uses the classic Reactor model. Reactor, as its name implies, means reactor. It does not process any data sending and receiving itself. It can only monitor the event changes of a socket (can also be a pipe, eventfd, signal) handle.

Reactor is just an event generator. The actual operations on the socket handle, such as connect/accept, send/recv, and close, are completed in the callback.

②Swoole's architecture

swoole uses multi-threaded Reactor and multi-process Worker.

When a request arrives, swoole handles it like this:

请求到达 Main Reactor
        |
        |
Main Reactor根据Reactor的情况,将请求注册给对应的Reactor
(每个Reactor都有epoll。用来监听客户端的变化)
        |
        |
客户端有变化时,交给worker来处理
        |
        |
worker处理完毕,通过进程间通信(比如管道、共享内存、消息队列)发给对应的reactor。
        |
        |
reactor将响应结果发给相应的连接
        |
        |
    请求处理完成

Because reactor is based on epoll, each reactor can handle countless connections ask. In this way, swoole can easily handle high concurrency.

The above is the detailed content of How Swoole handles high concurrency. 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
Previous article:How to test swooleNext article:How to test swoole

Related articles

See more