Server-side Push in Rails

前端 未结 5 1187
萌比男神i
萌比男神i 2021-02-10 10:36

I\'d like to implement a scalable chatroom in rails using AJAX. I know from research that the only scalability happens with a server-side push.

My two questions are:

5条回答
  •  眼角桃花
    2021-02-10 10:50

    COMET works by keeping the connection to the server open in Javascript (there are plenty of examples on how to get this async data on the COMET website). The server essentially writes the data out and flushes it, this can be done using a Mutex in a tight loop. You will also probably need a message queue of sorts.

    It might be better to learn about BOSH in the long run. It is the natural progression from COMET.

    Although Juggernaut has a learning curve (or it might not really), learning how to do COMET is a steeper one. Even just async pushing is harder. Not only that, but you then need to consider how to make it scale well. I have never used Juggernaut, but as far as ROR plugins go I assume it's trivial. And if they figure out how to make it scale better, you get faster performance for free.

    Polling is another options which should technically work out simpler, however, I am passionate about not using polling as it can kill your server - so I won't elaborate on it here because I feel that polling is the lazy route.

提交回复
热议问题