Reputation: 11299
I have a javascript-based client that is currently polling a .NET web service for new content. While polling works...I'm not happy with this approach because I'm using system resources and creating overhead when there aren't any changes to receive.
My question is how do I notify my client(s) that there is new content for it to display? I am open to on any additional technologies I would have to implement this solution with.
Upvotes: 6
Views: 2168
Reputation: 39697
First of all, polling is the way to go. You could do it with Flash or Silverlight or Comet - http://en.wikipedia.org/wiki/Comet_(programming) which can hold a tcp connection open for you for notifications. A webpage itself cannot hold a socket open, so there is no way to directly notify a web client.
[Edit]
But think about it, how many client can hold a tcp connection towards one server at a time? For a larger system you would run out of available sockets pretty fast as there are 65k ports available.
How many concurrent connections your server can handle depends on your hardware resources. If you have enough memory and cpu you should be able to handle ~100k and maybe more. But if each request access a database or some other resource over tcp/ip, you could be limited to the number of ports per ip available (65k). You should also have the push requests go against a separate domain, as a browser normally caps to two concurrent connections per domain, so you won't interfere with the normal page loading.
Using polling in combination with cache servers in the front is a good solution. You can have logic on the server which updates the cache per client, reducing the load for each poll. You could update the cache for users who have signed in/polled within the X number of minutes to reduce the cache updating even more. And to me implementing pull is easier than pull, technology wise.
Upvotes: 7
Reputation: 44632
Check out WebSync, a comet solution for .NET/IIS. It'll do exactly what you're looking for. No extra polling wasting resources, push only when needed, real-time updates...the whole 9 yards.
Upvotes: 2
Reputation: 294177
You've been already told about HTTP polling (COMET). This leaves open the question how does the http server itself (IIS+ASP) detect the changes in the database without polling the database. With SQL Server you can use a technology like Query Notifications, which allows your ASP.Net process to be notified when a change occurs in the database on a record it has cached. You can also check out the LinqToCache project that allows Query Notification to be mixed with LINQ queries.
Upvotes: 1
Reputation: 12078
http://www.ape-project.org/ is I think a good place for you to look. Its based on ajax push or as some call it reverse ajax. There are other projects as well and it is based on: http://en.wikipedia.org/wiki/Comet_(programming)
I mentioned ape project because you can use JavaScript with it or if you want C++, PHP, Python, etc on the server side. :-)
Upvotes: 1
Reputation: 68400
You should research about COMET.
COMET is a Technique that enable a server to push data to client browsers through an HTTP open line of communication.
Probably there are examples overthere about COMET + WCF Web services.
Upvotes: 2