Search code examples
asp.netsql-server-2008pollingbroadcastlivechat

Is polling the way to go for live chat on web?


I'm trying to implement a custom live chat program on the web, but I'm not sure how to handle the real-time (or near real-time) updates for users. Would it make more sense to send Ajax requests from the client side every second or so, polling the database for new comments?

Is there a way to somehow broadcast from the database each time a comment is added? If this is possible how would that work? I'm using Sql Server 2008 with Asp.net (c#).

Thanks!


Solution

  • Use long polling/server side push/comet:

    http://en.wikipedia.org/wiki/Comet_(programming))

    Also see: http://en.wikipedia.org/wiki/Push_technology

    I think when you use long polling you'll also want your web server to provide some support in the form of non-blocking io for requests, so that you aren't holding a thread per connection.