为什么以及如何推送通知(如GCM)电池效率? [英] Why and how is push-notification (like GCM) battery efficient?

查看:188
本文介绍了为什么以及如何推送通知(如GCM)电池效率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想要了解Google云消息传递(以前称为Google Cloud到设备消息传递)等推送通知的基本原因对于云设备通信更加电池友好吗?



在我看来,替代技术涉及轮询(通过TCP / IP),同时保持连接处于CONNECTED状态,使​​用保持活动。或者有什么更好的?



我对GCM有限的认识是,它也使用TCP / IP和keepalives,但客户端从不轮询服务器的状态。相反,服务器通知客户有关传入消息,而订阅特定类型消息的应用程序会异步通知消息。此外,通用的GCM连接在多个应用之间共享,从而允许设备电子设备在协调的时间进行休眠/休眠,而不需要多个应用程序保持电子设备比其需要的更开启(电活动)。这是正确的理解吗?或者还有更多吗?



最后,这与使用Keepalive的TCP / IP的MQTT相比如何?什么原因导致MQTT(显然)的电池效率低于GCM?

解决方案

其中一个主要原因是它效率高规模很好。 Android设备保持一个连接对GCM服务器开放,以侦听设备上所有应用程序的通知,然后将消息路由到他们打算使用的相应应用程序。这比保持网络连接为每个希望进行某种推送通知的应用程序打开的可扩展性和高效性要高。

连接本身可能是一个TCP连接,即使在电话闲置时仍保持打开状态。它可以在收到数据时唤醒设备。我会想象有一些心跳ping也可以在必要时重新建立连接。

套接字可能是您自己可以做的事情,但正如我之前所说的,效率的主要原因是所有应用程序的单一连接。非常具有伸缩性。


Wanted to understand the fundamental reasons for push-notification like Google Cloud Messaging (earlier called Google Cloud to Device Messaging) being more battery friendly, for cloud <--> device communication ?

In my view, the alternative technologies involve "polling" (over TCP/IP) while keeping the connection in CONNECTED state, using keep-alives. Or is there something better ?

My limited undertanding of GCM is that, it also uses TCP/IP and keepalives, but the client never polls the server for status. Instead the server informs the client about an incoming message, and applications who subscribe to certain type of messages, are notified of the message asynchronously. Also, the common GCM connection, is shared between multiple applications, thus allowing the device electronics to sleep / hibernate at "coordinated" times, without multiple applications keeping the electronics more "ON" (electrically active) than they need to be. Is this the correct understanding ? Or is there more to it ?

Finally, how exactly does this compare to MQTT over TCP/IP with keepalives ? What are the reasons for MQTT being (apparently) less battery efficient than GCM ?

解决方案

One of the main reasons it's efficient is it scales well. The android device keeps a single connection open to GCM servers to listen for notifications for ALL apps on the device, and then routes messages to the appropriate applications they are intended for. This is much more scalable and efficient than keeping a network connection open for every single application wanting to have some sort of push notifications.

The connection itself is likely a TCP connection that's left in an open state, even when the phone's goes idle. It can wake the device when data is received. I'd imagine there's some sort of heartbeat ping going on too that can have the connection be re-established if necessary.

The socket stuff is probably something you could do yourself, however like I said earlier the main reason for efficiency is the single connection for all apps. Very scalable.

这篇关于为什么以及如何推送通知(如GCM)电池效率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆