-1

In database some entity is getting updated by some backend process. We want to show this updated value to the user not real-time but as fast as possible on website.

Problems we are facing with these approaches.

  • Polling :- As we know that there are better techniques then polling like SSE, WebSockets.
  • SSE :- In SSE the connection open for long time(I search on internet and found that it uses long polling). Which might cause problem when user increases.
  • WebSockets :- As we need only one way communication(from server to client), SSE is better then this.

Our Solution

  • We check database on every request of user and update the value.(It is not very good as it will depend upon user next request)

Is it good approach or is there any better way to do this or Am I missing something about SSE(misunderstood something).

Is it fine to use SignalR instead of this all?(is there any long connection issue in it or not?)

Thanks.

yajiv
  • 2,901
  • 2
  • 15
  • 25
  • I think you should try to use some client side library for data handling on UI like knockout.js and keep sending web-request to an API in the backend. When data in modified by API then knockout will automatically update UI. I think this approach is better than going for some complex ways. – Abhishek Maurya Nov 21 '17 at 09:13

2 Answers2

1

It's just up to your requirements what you should use.

Options:

  1. You clients need only the update information, in the case they make a request -> Go your way
  2. If you need a solution with different client types like (Webclient, Winformclient, Androidclient,....) and you have for example different browser types which you should support. Not all browsers support all mechanisme... SignalR was designed to choose automatically the right transport mechanisme according to the mechanisme which a clients supports --> SignalR is an option. (Read more details here: https://www.asp.net/signalr) Has also options that your connection keeps alive.
  3. There are also alternatives like https://pusher.com/ (For short this is only a queue where you can send messages, and also subscribe for messages) But these services are only free until for example some data volume.
Stephu
  • 3,236
  • 4
  • 21
  • 33
-1

You can use event based communication. When ever there is a change(event) in the backend/database, server should send a message to clients.
Your app should register to respective events and refresh the UI when ever there is an update.
We used Socket IO for this usecase, in our apps and it worked well.
Here is the website https://socket.io/

Chamu
  • 194
  • 5