Home > PHP Framework > Swoole > body text

How Swoole handles high concurrency

(*-*)浩
Release: 2019-12-07 13:32:03
Original
2889 people have browsed it

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将响应结果发给相应的连接
        |
        |
    请求处理完成
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!