简体   繁体   中英

Long polling for real time messages/updates

What is a good strategy for implementing long polling in a .Net application.

Would it mean having a JS setInterval() based approach to keep polling the server for updates that can be rendered on the page. I have always thought that that could be a challenge when it comes to scalability as it seems it would generate a lot of extra requests to the web server. I have read that this type of functionality should be implemented using a non blocking web server (single threaded) NODE.js etc... Since there's only one thread/event loop it seems like the requests would have to be very lightweight to service several requests in a timely fashion. Can Node.Js trigger db calls?

I have seen an online dating site where you receive notification in the form of a fad-in/fade-out popup when someone visits your profile when you're currently logged into the system. I am impressed that something like that can work so well for a high volume site.

Is it reasonable to assume that this type of notification system is implemented using long polling? Based on constantly polling through JS?

I am seeing similar behind the scenes updates her on the SO site as well (messages/votes etc) Does this use a similar strategy as well?

Realtime web applications have been with us for quite some time now: the history of Polling goes from setInterval Technique to HTML5 WebSockets .

Here you can find Simple Long Polling Example with JavaScript.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM