PubNub长轮询vs套接字 - 移动电池寿命 [英] PubNub long polling vs sockets - mobile battery life

查看:250
本文介绍了PubNub长轮询vs套接字 - 移动电池寿命的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始在我的iOS应用程序中使用PubNub,并且非常满意。但是,我一直在寻找其他可用的选项,例如使用Websockets的Pusher和Realtime.co。另一方面,PubNub使用长轮询。我已经完成了自己的小速度比较,为了我的目的,我发现它们都足够快。

I recently began using PubNub in my iOS app, and am very happy with it. However, I have been looking at the other options available, such as Pusher and Realtime.co, which use Websockets. PubNub, on the other hand, uses long polling. I have done my own little speed comparisons and for my purposes, I find that they are all fast enough.

PubNub提供了一些不错的功能,如消息历史记录和每个人的列表在频道中,所以除了我倾向于他们的一切。我的问题是,我应该关注像PubNub这样的长轮询解决方案的电池寿命和大量使用吗? Websockets解决方案是否会显着提高功效?

PubNub offers some nice features like message history and a list of everyone in the channel , so barring everything else I am leaning toward them. My question is, should I be concerned with battery life and heavy usage with a long-polling solution like PubNub? Would a Websockets solution be significantly more power efficient?

推荐答案

手机上的PubNub具有省电功能



作为电池性能和效率的前言,与替代或自托管的websocket解决方案相比,PubNub是移动设备的优化服务。 PubNub在移动电话上提供了一个追赶功能,可以自动重新发送丢失的消息,特别是对于在小区网络塔之间移动并从3G / 4G更改为WiFi的设备。由于常见情况下的可靠性,Websockets往往不推荐用于移动设备,这就是PubNub将自动为您的设备选择最佳传输的原因;所以你不必决定什么对传输中的手机最有意义。

PubNub on Mobile with Battery Saving

As a preface to battery performance and efficiency, PubNub is an optimized service for mobile devices on-the-go when compared to alternative or self-hosted websocket solutions. PubNub offers a catch-up feature on Mobile phones that will automatically redeliver messages that were missed, especially for devices that are moving between cell-network towers and changing from 3G/4G to WiFi. Websockets tend to be unrecommended for mobile due to reliability in common scenarios and that is why PubNub will select the best transport for your device automatically; so you don't have to decide what makes the most sense for the phone in transit.

PubNub具有一个非常长的保持连接,并设置为一小时。每300秒(300,000ms)发送一次ping。这足以提供移动性能和省电之间的最佳组合。

PubNub has a keep-alive connection that is uncommonly long and set to one hour. A ping is sent each 300 seconds (300,000ms). This long enough to provide the best mix between mobile performance and battery saving.


  1. 保持消息尽可能小。

  2. 减少发送频率较少的消息。

  3. 仅连接一个频道而不是两个频道或更多。



自动运输检测



PubNub会自动选择最佳在需要时为您传输,尤其是在移动设备上。关于websockets的一个有趣的对话发生在2012年10月在KRTConf的俄勒冈州波特兰市,我建议你 https:/ /speakerdeck.com/3rdeden/realtimeconf-dot-oct-dot-2012

Automatic Transport Detection

PubNub will automatically select the best transport for you when needed especially on mobile devices. An interesting conversation about websockets occurred in Portland, Oregon this last October 2012 at KRTConf that I recommend to you https://speakerdeck.com/3rdeden/realtimeconf-dot-oct-dot-2012

请告诉我这是否有用。

这篇关于PubNub长轮询vs套接字 - 移动电池寿命的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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