nginx cannot link swooleWhat should I do?
Method of mixing nginx and swoole
Nginx based on epoll
With epoll, theoretically one process can have an unlimited number of connections, and no need Polling really solves the problem of c10k.
Nginx is an asynchronous non-blocking server program based on epoll. Naturally, it is understandable that Nginx can easily handle millions of concurrent connections.
How swoole handles high concurrency
①Reactor model introduction
IO multiplexing asynchronous non-blocking programs use the classic Reactor model. Reactor, as the name suggests, means reactor, and it does not process it itself Any data sent and received. It can only monitor the event changes of a socket (can also be a pipe, eventfd, signal) handle.
Note: What is a handle? The English word handle is handler, which can be vividly compared to the handle of a pot or a spoon. That is, the unique identifier of the resource and the ID of the resource. Resources can be operated through this ID.
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.
Because reactor is based on epoll, each reactor can handle countless connection requests. In this way, swoole can easily handle high concurrency.
nginx configuration:
9501 is the address that the swoole server listens to. root is set to the directory of static files. When requesting a static file, it is processed directly by Nginx. When the requested file does not exist, it is sent to the Swoole server for processing.
The above is the detailed content of What should I do if nginx cannot connect to swoole?. For more information, please follow other related articles on the PHP Chinese website!