Home  >  Article  >  PHP Framework  >  What should I do if nginx cannot connect to swoole?

What should I do if nginx cannot connect to swoole?

藏色散人
藏色散人Original
2020-04-09 09:49:242242browse

What should I do if nginx cannot connect to swoole?

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:

What should I do if nginx cannot connect to swoole?

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!

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