简体   繁体   中英

Web Sockets vs Interval Polling

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?

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM