How Facebook uses Erlang for real-time chat
gregosuri.com
gregosuri.com
I almost didn't read this article due to the "isn't this a bit old" comments here, but, am very glad I did.
First of all, they rolled their own epoll-based server for the whole chat system.
Then, instead of using a 'sane' comet/long-poll implementation based on JSONP (to avoid limitations of same-domain requests), it seems that they used a scheme where the chat nodes have a fake subdomain like 'http://N.subdomain.facebook.com/.... I don't know how efficient this is supposed to be, but I haven't seen that too often.
Of course, it's wholly possible their Erlang implementation of the chat system is the reason why it fails. Personally, I have never had much trouble with their chat, although I haven't used it much either.
Their solution seems to work well, anyway.
In any case, they don't solve the same problem. Jsonp solves the problem of talking to another domain (PostMessage does the same thing). Channels solve the problem of the browser limiting the number of concurrent HTTP requests you can have open to one domain.
Another problem that I had encountered was about BOSH. From what I had read in the RFCs, the BOSH session is based on random seed that you hash over and over in SHA (say 200 times). The server then just has to SHA your message to find the hash of the previous message. This, coupled with the basic session identifiers effectively makes it relatively complex to have the chat working over multiple windows or tabs.
There might be other reasons, but those are the obvious ones to me.