Web套接字与间隔轮询 [英] Web Sockets vs Interval Polling

查看:103
本文介绍了Web套接字与间隔轮询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在寻找最合适的解决方案来处理通知.我当前的选择是使用websocket还是只进行轮询(每分钟仅1个请求,不再进行长时间轮询,也不会进行永久轮询)

I'm currently looking for the best fitting solution to handle notifications. My current options are either using websockets or just do a polling (only 1 request every minute, no long polling, no permanent polling)

在某种程度上,我很难找到这些方法的性能指标.结果应该能够并行处理很多用户,而不会占用太多资源.

I somehow have problems to find performance indicators for these methods. The result should be able to handle a lot of users in parallel without taking too much resources.

  • 每30秒发送一次请求,以检查用户是否有新通知
  • 每个用户都拥有一个websocket连接,并直接收到有关新通知的通知

在后端,我使用带有Spring Boot的Java Spring.您知道任何最佳做法或参考实现吗?

In the backend i'm using java spring with spring boot. Do you know any best practices or reference implementations?

推荐答案

我建议使用选项A,因为您只需要快速响应并且不希望实时提供更多信息.您还会说到许多用户,因此在一定的时间间隔内请求用户通知的资源消耗应比为每个用户保持打开的Websocket少.这还取决于您的环境.

I would suggest to use option A since you just need a quick response and dont want to deliver further information in real time. You also speak of many users so it should be less resource consuming to request user notifications in a certain timeinterval than keeping an open websocket for each user. it also depends on your environment.

也可以在这里查看: 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆