Socket.io: Real time web app persistence trade offs

时间:2015-10-29 15:47:03

标签: mongodb websocket socket.io real-time nodes

I have a real time app that I have already built. After reading some documentation on googles real time api, or mozilla's togetherjs I'm questioning my currently architecture. Obviously their are trade off's in terms of persistence (which I need to restore state) and speed of the updates. Here's the basic model I have now:

Client changes object -> client does a POST to server -> its persisted to Mongo -> Server broadcasts updated object via socket io to every client that cares

This guarantee's persistence but sometimes I feel its slows down the real time updates. The model I'm considering:

Client changes object -> broadcast object change via socket io to all clients that care (hub/spoke model) -> then fires a POST to server -> store in Mongo

In this model the clients aren't waiting for the roundtrip to the database, which seems faster. A third model I've considered:

Client changes object -> broadcast object change via socket io to all clients that care (hub/spoke model) -> server asynchronously stores in Mongo

I feel like its a tradeoff of speed and up to date persistence. Just wanted to get someone else's take on it.

0 个答案:

没有答案