Long polling for real-time messages / updates

What is a good strategy for using long polls in a .NET application.

Will this imply using JS setInterval () to poll the server for updates that may appear on the page. I always thought that this could be a problem when it comes to scalability, as it seems to create a lot of additional requests to the web server. I read that this type of functionality should be implemented using a non-blocking web server (single-threaded) NODE.js, etc .... Since there is only one thread / event loop, it seems that requests should be very lightweight in order to be timely Serve multiple requests. Can NODE.Js trigger db calls?

I saw an online dating site where you receive a notification in the form of a fad-in / fade-out pop-up window when someone visits your profile when you are currently logged in. I am impressed that something like this can work so well for a high volume site.

Is it possible to assume that this type of notification system is implemented using a long survey? Based on continuous polling through JS?

I see updates behind the scenes on the SO site (messages / voices, etc.) that are similar. Does this use a similar strategy?

+6
source share
2 answers

Real-time web applications have been with us for quite some time: the survey history goes from setInterval Technique to HTML5 WebSockets .

Here you can find an example of a simple long survey using JavaScript.

http://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery

+4
source
+7
source

Source: https://habr.com/ru/post/912102/


All Articles