0

ReactPHP http server for each user, Is this a good idea?

In my application:

  1. Each logged on user sends and receives data from server. In average one request per second.
  2. After server response, the server have some extra work to do, which is related to specific user.

I can simply build new ReactPHP http server for each user who logs, and release the server after the user log out.

Is this will work? Am i missing something ?

4

1 回答 1

1

不,这不是一个好主意。在这种情况下,您需要每个用户有一个单独的端口来将用户路由到正确的服务器。那会很快耗尽你的端口。

如果您在事件循环中有阻塞任务并因此想要使用多个进程,只需坚持使用传统 PHP 的mod_phporphp-fpm并为每个进程启动一个新的事件循环,执行您的操作然后退出。

如果你没有任何阻塞操作并且一切都是非阻塞的,你可以只使用一个服务器来处理所有的事情。

于 2017-02-07T11:18:47.120 回答