每个用户都有ReactPHP http服务器,这个好主意吗?(ReactPHP http server for each user, Is this a good idea?)

编程入门 行业动态 更新时间:2024-10-25 12:19:46
每个用户都有ReactPHP http服务器,这个好主意吗?(ReactPHP http server for each user, Is this a good idea?)

每个用户都有ReactPHP http服务器,这个好主意吗?

在我的申请中:

每个登录用户都从服务器发送和接收数据。 平均每秒一个请求。 服务器响应后,服务器还有一些额外的工作要做,这与特定用户有关。

我可以为每个登录用户构建新的ReactPHP http服务器,并在用户注销后释放服务器。

这会起作用吗? 我错过了什么吗?

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

In my application:

Each logged on user sends and receives data from server. In average one request per second. 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 ?

最满意答案

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

如果你在事件循环中有阻塞任务并且想要使用多个进程,那么只需坚持使用mod_php或php-fpm传统PHP并为每个进程启动一个新的事件循环,做你的事情然后退出。

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

No, it's not a good idea. You need a separate port per user in that case to route the user to the right server. That'd quickly exhaust your ports.

If you have blocking tasks within the event loop and want to use multiple processes because of that, just stick to traditional PHP with mod_php or php-fpm and start a new event loop for each process, do your thing and then exit.

If you don't have any blocking operations and everything is non-blocking, you can just use a single server and it handles all the things.

更多推荐

本文发布于:2023-07-15 21:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1119348.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:都有   好主意   服务器   用户   ReactPHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!