[erlang-questions] Any message queue model in Erlang when doing Comet chat?
Wed Jul 22 14:18:32 CEST 2009
Do you have messages in a chat room persisted on the server (in MySQL) ? If
so then I think what you are doing are fine. Every time a client connects
it says: "give me all messages newer than time T" and if such messages exist
the server delivers them to the client, otherwise it just holds the
connection until the next message arrives or the 10 sec. time out occurs.
What are your requirements for fault tolerance? Do you actually need to
persist the chat rooms, or would it be ok to just hold them in RAM in the
server? Maybe you can just cache the last few messages for each chat room
in RAM, that way you would only need to touch the DB when a new client
connects to a given room (maybe a DB can do that for you, I'm no DB expert).
Maybe flat files would scale better than a RMDB?
On Wed, Jul 22, 2009 at 3:12 AM, Zhuguo Shi <blueflycn@REDACTED> wrote:
> Hi Peter,
> I did the checking by sending messages in a high frequency, like you enter
> some letters and press the "send" button quickly. My comet chat is like
> Facebook's and the polling connection is automatically disconnect and
> reconnect in 10 senconds (Facebook is about 50 seconds). So I doubt if you
> send a message to a user that just disconnected and have not connected, the
> message will lost.
> The test result is not good before I added the database sync mechanism. I
> am not sure if there is any problem in my code or test. I did this comet
> chat prototype just according to Richard's series (
> Any suggestions?
More information about the erlang-questions