swoole can be clustered.
ClusterCluster
Server nodes can be divided into 3 roles
The entry node can also be called the GateWay gateway. External users directly connect to the AccessNode through TCP, and the AccessNode maintains a long connection with the client and performs data interaction.
Web service cluster, Nginx is AccessNode (GateWay), the browser connects to Nginx through the external network, and Nginx parses and processes the request. If it is a static file request, the file content is sent directly to the client. If it is a dynamic php request, Nginx forwards it to the back-end PHP-fpm or other language application server for processing.
WebIM, WebIM generally uses Http long polling (Comet) or WebSocket as AccessNode, and the browser is directly connected to swoole_websocket_server to realize real-time interaction of messages.
AccessNode must be fully asynchronous to ensure that the entire system can handle a large amount of concurrency. AccessNode needs to monitor the external network,
ServiceNode
service node, and all business logic is completed in ServiceNode. Large-scale Web websites are also subdivided into the Web layer and the logic layer. The Web is only responsible for front-end display, and all real business logic is placed on the back-end logic layer Server.
Recommended learning: swoole video tutorial
The above is the detailed content of Can swoole be clustered?. For more information, please follow other related articles on the PHP Chinese website!