问题描述:

There're many highload sites notify their users about new messages/topics runtime, without page reloading. How do they do that? Which approach do they use?

I assume there's two approaches:

  • "Asking" the server using JavaScript each time gap
  • Use websockets

By common opinion, the first one is too heavy for the server, since it produces too many requests.

About second one's behaviour in highload apps I know nothing, is it fine one?

So, which design approach to use to implement functions like "new msg available" properly without the need to reload the page?

The question rather about performance :)

网友答案:

WebSocket performance in the browser is not an issue, and on the server side there are performant implementations. As an example, Crossbar.io can easily handle 180k concurrent connections on a small server (tested in a VM on an older i5 notebook), and 10k/s messages - and both scale with the hardware (RAM and CPU respectively). Also: Something like Crossbar.io/Autobahn/WAMP gives you a protocol on top of WebSockets to handle the distribution of notifications to clients, making your life easier.

Full disclosure: I work for the company that works on Crossbar.io, and there are other WebSocket and PubSub solutions out there. Take a look at what best fits you use case and go with that.

相关阅读:
Top