Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 368
Frnak Avatar asked Mar 10 '23 22:03

Frnak


1 Answers

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?

like image 133
hasan Avatar answered Mar 21 '23 09:03

hasan