3

My site needs a chat room, and I'm also looking to implement a facebookesque person to person chat system.

What is most cost-efficient/performant (purely in terms of bw and server) for me. A regular 1 second poll ajax chat, or a comet solution.

Thanks.

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
Mark
  • 32,293
  • 33
  • 107
  • 137

1 Answers1

1

Comet would typically result in lower bandwidth usage (assuming less than 1 chat message per second per chat on average), owing to the fact that it will only query the server once per message sent. It would typically result in more concurrent active connections to your server though.

This blog article may help you visualise it better.

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
  • Thanks for the link, but that is a pretty biased article. I understand that comet results in lower bw use, but what about server resources? Thanks. – Mark Feb 02 '10 at 22:32
  • Yeah, it is. Remember though, for each HTTP connection you have to do the whole TCP/IP handshake, which is a relatively expensive set of operations. So by polling every second you are smashing your server pretty quickly with raising user counts. Everything depends on how many clients you expect to have on your server at a time, since it all comes down to scale. I think if you get to the point where you really have to be concerned with server resources used by comet, your probably already at the point you need multiple servers and load balancers... – Dan McGrath Feb 02 '10 at 22:57
  • @Dan Isn't it true that the default connection mode for HTTP 1.1 is "keep-alive" ? So there's not alot of TCP/IP handshakes going on even with a large number of HTTP requests right? – Pacerier Jul 03 '12 at 02:43
  • 1) Yes, 2) Partially. For example, Apache 2.2 only keeps those connections open for 5 seconds by default. So in the case of a chat room, 10K online users would produce 120K handshakes per minute when no-one is talking. There are a lot of optimization you can get in to such as delaying chat messages to aggregate, but in general I believe my answer still holds. – Dan McGrath Jul 03 '12 at 05:03