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?
SignalR and pokein are two good options.
A blog post by scott hanselman which explains using SignalR
http://www.hanselman.com/blog/AsynchronousScalableWebApplicationsWithRealtimePersistentLongrunningConnectionsWithSignalR.aspx
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
Related
we are in a situation where millions of connections (approximately 30 million) will be connected to application. (SignalR Hubs)
however 90% of them will be idle and main operation is server push to specific client thus i need to implement a scale out mechanism.
so i came across this fantastic talk on channel 9 by Damian Edwards where he states that current implementations of backplanes for SignalR is very limited and in scenarios like mine a Custom scale out is needed specifically in server push situation. (at 58:29 of above talk)
after spending many hours in web, i could not find any clear guidance on how to implement a custom backplane which suits my need.
i would like to know how signalR back plane internally works and basically how a backplane works in general. so i can implement my own one.
any help, blog post etc.. is highly appreciated.
Please read this piece of documentation, specifically the piece regarding Implementation.
TL;DR -
When a message is sent, it goes to the backplane, and the backplane sends it to every server. When a server gets a message from the backplane, it puts the message in its local cache. The server then delivers messages to clients from its local cache.
I am using C# ASP.NET MVC 4 Razor
I have a Grid in ASP.NET MVC Razor View that displays the user records. Is there any way to show the new users in Grid without sending the async request to server after each 1 min ?
I searched on Google a lot. Now, finally I am posting the query here to get any clue for this solution to avoid Traffic on Server. As this page will be visible to at least 20,000 users
#Christos approach is the right one!, Just to add more info about it for an ASP.NET solution I would it use SignalR, that lets you implement a simple server/client communication and it's cross browser (it has several polyfills that if it cannot use web sockets it will use server-sent event, and so on), and the best part is that you don't need to worry about that implementation.
Once your clients are connected to the signalR server you can notify them everytime you need to add a new item to the grid.
http://www.asp.net/signalr/overview/getting-started/tutorial-server-broadcast-with-signalr
I hope it helps!
You could make use of the the publish/subscriber pattern. This can be done using for instance a redis server.
In software architecture, publish–subscribe is a messaging pattern
where senders of messages, called publishers, do not program the
messages to be sent directly to specific receivers, called
subscribers. Instead, published messages are characterized into
classes, without knowledge of what, if any, subscribers there may be.
Similarly, subscribers express interest in one or more classes, and
only receive messages that are of interest, without knowledge of what,
if any, publishers there are.
Please have a look here.
Doing so, the first time a client requests data from the server will subscribe to the server for taking any updates. Once any update arrives, the server will push the update to the clients that have subscribed, without requiring from the client to make any other request to the server.
As for implementation details, please have a look here.
I'm currently designing a live analytic site using Asp.Net + C#, I was wondering what is the best method to transmit the data from the server to the client, here is what I've thought of so far;
Using Asp.Net AJAX UpdatePanel, and regularly update it with a timer
using JavaScript.
Create a server application (In C#, Java, Node.Js or Ruby) and use
Socket IO to retrieve a constant stream of data from it.
Create a JSON web service which returns large amounts of data, I
could use JQuery/AJAX to request it and process it in real-time on
the page.
Do any of these seem a good idea, or are their any other options?
I would never use the update panel, it would be too heavy for what your doing. Regular ajax calls would work just fine and write up a webApi service. Websockets would work well too, but is a little more complex. Depending on your time, you might want to check out SignalR which is a websocket client solution that can fall back to polling if the browser doesn't support websockets.
I am building simple notificiation system and I just wanted to know what is the best technique to use to do the job, right now I am doing AJAX requests to server every 30 secs per user to check for new notifications.Since this will be entertainment site it is not crucial for notifications to be pulled in realtime. My main concern is browser support, conserving server resources and scalability, so which technique would best fit the job?
Try SignalR
http://www.hanselman.com/blog/AsynchronousScalableWebApplicationsWithRealtimePersistentLongrunningConnectionsWithSignalR.aspx
I've been trying to build a web based chat application for the past three weeks and i'm facing issues with whatever route (programming technique/technology) i take to build it. I've explained the issues i've experienced with all of'em below. Kindly provide whatever insights you have in this.
ASP.NET-AJAX
First issue is that it is Not Really Real Time
If client hits the chat server every x seconds (constant time stamp) it is not going to be real time unless x is very very less
If x is very small like 1 second and if there are 1000 users online at the same time i think it is really going to hammer the chat server and cause scalability/performance issues
WCF-Duplex
I unfortunately wasted considerable amount of time in this trying to build a WCF duplex service which maintains all the clients and invokes the client through the channel as and when required. But i recently learnt that WCF duplex callback wont work with ASP.NET (since http is request and respond type). I was following this great article to build a duplex service.
Comet/ReverseAjax/HTTP Server Push
I'm extremely new to this technique and wonder how well enough it can scale. After my first glance on this programming technique here in wiki and the very first article on Comet by Alex here, i learned that the client always maintains an open connection (long living ajax calls) to the server which can be used by the server to push "interesting events happening in the server" to the browser (client). So how well can it scale? What if the max no of open connections exceed in IIS or any other issues like that?
Jabber Server/Client (XMPP)
I see that most of the prominent chat applications that can be seen online are making use of Jabber. I also learned that writing a Jabber server from the scratch is a tedious task. I have separate user profile store for by application. Can i integrate that with Jabber easily? Any open source Jabber servers that i can host privately? (I've seen many open source tools to build the client easily)
Any insights provided are very much appreciated.
Thank you
NLV
If you are using .NET, check out WebSync. It allows for fully scalable comet using IIS to integrate directly with your application. There is a free Community edition you can try out, along with tons of examples and chat demos.
I just recently implemented a multi-client Jabber web-app using WebSync and jabber-net.
PokeIn provides shared objects among the clients and it simply helps you to create impressively solid and fast web applications. Even if your application is hosted on multiple servers, PokeIn manages the shared objects on all of them. So, this feature will help you to create quite effective solutions. In addition to these, you will find very useful samples over there
I know this is old but if somone new founds this you should consider using SignalR
Open Source Jabber Server
Have you checked out OpenFire