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