abetusk / bostontraintrack

Simple real time tracking of the Boston Red, Orange and Blue metro lines using Open Street Map (via OpenLayers) and the MBTA's real time metro tracking. (service is now shut down)
GNU Affero General Public License v3.0
32 stars 6 forks source link

Transmit delta instead of whole refresh #8

Closed abetusk closed 10 years ago

abetusk commented 10 years ago

As it stands, the server retransmits the entire positions of the marker locations to each of the clients. This can be slimmed down to only transmit additions, deletions and updates of elements when they happen. I can imagine this might be a bit brutal for mobile devices.

abetusk commented 10 years ago

This will brutalize any mobile data plan under the current framework, so I'm turning this into a bug.

Friss commented 10 years ago

So it would probably be a good idea on the server side to keep a copy of the data from last poll and then modify that data and have a property on each entry like

status: update status: delete (Guessing this would be where the entry is in the old and not the new). status: add

That can be then used on the client side to update its configuration of the markers. Probably would be a good idea to update the markers already existing or destroy them if they are marked as such. This will probably be easier on the client side as well.

abetusk commented 10 years ago

The server should be able to figure out which entry needs updating, removal or creation. Whenever a client connects, the whole snapshot is sent. Whenever the server detects a single change, it can immediately can push to all connected clients, be it an update, removal or creation.

The client needs to make sure it can process single changes.

Not necessary, but a 'nice to have' feature would be to periodically send some sanity check data, like a checksum or other digested information, to make sure the client and server are in sync. If they aren't a whole snapshot is sent. This way the new system should be no worse than the old one.

Another nice to have feature would be to detect when the number of deltas exceeds a threshold in a short amount of time and just send the snapshot instead. This is probably unnecessary right now, but something to consider for later.