What is the suggested pattern for providing realtime UI updates in a web application? For example, whilst answering a question on SO and another user submits an answer and a prompt appears. Also, if every page in your site provides this function, how do you avoid overloading the server with too many AJAX calls?
views:
160answers:
2
+1
A:
I think that using Comet for this will be one approach.(Comet Info here and here)
With Comet you can push the answer or whatever info you have on the server when you have the info, so you won't be requesting the info from the client every X time.
But as a Drawback as, tvanfosson and Josh make me notice, that it will keep the HTTP connection blocked in a client read state for extended periods.
Quaky
2008-12-24 18:04:28
Actually I think this is not particularly a good idea. I can't see how it would scale very well as it relies on keeping a connection open for potentially long periods of time. When the number of connections grows this stresses your web server as the network resources get used but not released.
tvanfosson
2008-12-24 18:11:11
This is fine if you only a handful of users. A quad proc box could only support 400 concurent users....neat idea just not practicle for large scale
JoshBerke
2008-12-24 18:12:48
Yes, I think that won't scale much up. WE used this approach, but we did not have a massive amount of users like SO.
Quaky
2008-12-24 18:14:14
+3
A:
Just run a timer and poll the server via XmlHttpRequest
. It's not like you need instant updates; AFAIK, SO polls on a 30-second interval, but that's too slow for me so i rigged up a Greasemonkey script to check every 15 seconds.
Shog9
2008-12-24 18:09:22