简体   繁体   English

使用一个大数据包还是更多小数据包更好?

[英]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 1)当电话请求时,发送包含所有电话信息的单个更新

2) Any time a phone updates a delta with just that information is sent to all the other phones 2) 任何时候,只要一部手机更新了 delta,该信息就会发送到所有其他手机

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编辑:为了清楚起见,传递的是一个简单的位置对象,所以它要么是一个位置对象数组,要么是一个位置对象的数组,要么更频繁地是单个位置对象,这将超过 4G 或 wifi,无论是什么可用的

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.但是,较小的数量可能会受益于差异同步,例如 git json 补丁。 Google published an article on it: https://research.google.com/pubs/pub35605.html谷歌发表了一篇关于它的文章: 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或者,对于小数据包,您可能会受益于使用 MQTT 协议和库,例如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.关于数据持久性和同步, https://realm.io有一个很好的解决方案,因此它可能会加速您的项目。 I've only started using that DB on a personal project.我才开始在个人项目中使用该数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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