简体   繁体   中英

Is it better to use one large packet or more smaller packet?

Im working on a mobile project that involves gathering data from multiple phones that is then distributed to all the phones. Would it be better(power/data usage) to:

1) Send out a single update with the information from all the phones when a phone requests

2) Any time a phone updates a delta with just that information is sent to all the other phones

I am assuming each phone will have a diffrent update frequency.

EDIT: For clarity what is being passed is a simple location object, so it would be either a array of locaiton objects less often or single location objects more often, this will be over 4G or wifi whatever is avalable

It depends on how much data will be transferred and the frequency. If there are multiple changes that can be lumped together maybe you are bettered off sending it as a compressed binary to the server.

However, smaller amount might benefit from differential synchronisation something like git json patches. Google published an article on it: https://research.google.com/pubs/pub35605.html

Alternatively, for small packets of data you might benefit using the MQTT protocol and libraries such as https://github.com/eclipse/paho.mqtt.android

In regards to data persistence and sync, https://realm.io has a good solution going so it might speed up your project. I've only started using that DB on a personal project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM