Web Sockets vs Interval Polling

余生长醉 提交于 2019-12-13 14:52:58

问题


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.

Option A:

  • Every 30 Seconds a request is sent to check if the users has a new notification

Option B:

  • Each users holds a websocket connection and is directly informed about a new notification

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


回答1:


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.

have also a look here: How many system resources will be held for keeping 1,000,000 websocket open?



来源:https://stackoverflow.com/questions/39959428/web-sockets-vs-interval-polling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!