Search code examples
.netsignalrpollinglong-polling

Update content to client in near real time: polling vs long polling vs signalr?


We have a website where the user can fill input form and submit his/her contact number to get loan approval. Once the user submits the form, we accept it on the server side and send an immediate response (while we relay this request to some third party API in the background). While we allow the user to browse other sections of the website, we want to show loan approval report based on his number as soon as we get it from the external API.

One way to do this is by:

  1. Polling as user moves to any new page (OR at regular intervals)
  2. Ajax Long polling
  3. Using SignalR. I find it apt to use this here. But I was wondering if this is the right fit for our situation. Also, I was a bit apprehensive in using this considering server resources and performance as I read in signalr "The connection between the client and server is persistent, unlike a classic HTTP connection, which is re-established for each communication."

Solution

  • SignalR would be useful in this scenario.

    On your server you can have signalR connected to client with client side script ready to do fancy notifications. When you get response back from API you can then notify customer (call the client script with connection ID) if they have passed or failed credit check or loan has been approved, pending or take more time.