3
gitpush
7y

Question: which is better approach?

1. Use push notifications to tell react website that new data is available

OR

2. Use SignalR (similar to socket.io) and push data in real time?

The down side of SignalR is server needs to map connections --> use more memory while push notifications doesn't require that

Comments
  • 2
    websockets?
  • 1
    Simple is push notification. How you are going to implement this?

    And I tried sockets before gave me lot of troubles.
  • 0
    @stop yup
    @zokazavevu in this case I do not handle connection state, it is handled by SignalR, I only listen to connection state and messages sent from server

    As for push notifications I already have it implemented but client sometimes doesn't receive notification instantly, while after adding SignalR client is instantly receiving message

    But I'm wondering to what limit the server will handle mapping connection IDs from clients
  • 3
    setInterval(function(){
    document.reload()
    },5000)

    There, perfect solution
  • 1
    @gitpush pushing is not the only option.
    If we are talking about a website and notifications which aren't occuring constantly, I'd argue that it's better to just request them with XHR with fitting interval.
    Don't keep connections open if it's not required.
  • 0
    @sharktits but this means I'm making server work when it shouldn't @joas in my case there are certain events on server that must cause the client to update, there is no specific time for those events and they randomly happen, that is why I am using SignalR and only on the pages that need to update, if user goes to a different page I close that connection and rely on push notifications
  • 1
    @gitpush That's the case I ment then: there's no need for low latency communication like in gaming. Client could check once in a while for example if the page version number, that increses after those events, is greater than the one which is currently shown. If the tab is active of course.
  • 1
    I prefer to use SignalR because polling is a dumb way to do it...

    However, it all depends on the scenario... Websockets have low overhead but do maintain a connection to the server... Push notifications do not necessarily mean "real time" notifications... Polling makes unnecessary trips to the server and, as a result, more traffic for the client...

    Well implemented SignalR is the go to solution for me... It is light on load and is scalable. Can be used with server farms and load balancers easily...
  • 1
    @joas I know understand your point, I'll do some restrictions on connection to make sure it is not kept when not needed
    @mmcorreia what is a well implemented SignalR? It is the first time I use it, and need to check if I did it correctly
  • 0
    @notcool Rabbit mq looks great though too much for my needs, I just need to signal the client that there is something new on the server without pushing the new data, the client will then connect to server and get those data

    Though maybe in the future I might just send what is new to reduce the load on the server, and just send what is new on the same connection and not have to open a new open to call API
  • 1
    If you care about it working on dumb browsers, use SignalR.
  • 0
    @spongessuck dumb browsers? So service workers doesn't work on any browser :S

    Thanks for letting me know about it, guess I need to rely more on SignalR and make push notifications as the last hope
Add Comment