android - 为上游 google gcm 构建 xmpp 服务器

标签 android google-cloud-messaging xmpp ejabberd

假设有一个应用程序在给定时间点有数千万次安装和数万个活跃用户。我需要将用户的 Activity 数据记录到我的服务器。目前,我从设备向我的服务器发出 HTTP 请求。我有一堆运行网络服务器的机器,坐在亚马逊的 ELB 后面。他们解析来自设备的数据并将其放入 mongodb。

现在,我想通过使用 Google 的 GCM 提供的上游 CCS 来捕获设备数据(这样我就可以搭载 GCM 以更可靠地传输数据)我已经编写了一个原型(prototype) XMPP 服务器,我可以使整个工作正常进行,但我担心扩大规模。如果 Google 开始以快于我消费的速度向我发送消息,会发生什么情况?早些时候,我能够在负载均衡器后面使用多个服务器来解决高请求率问题。这里有负载均衡的概念吗?

如果我打开从我的服务器到 Google 服务器的多个连接(Google 说我可以为给定的发件人 ID 建立 1000 个连接),传入的请求是否会在这些连接之间进行负载平衡?

最后,是否有推荐的解决方案可以解决上述大部分问题?使用 ejabberd 会解决上面的一些问题吗?

非常感谢。

最佳答案

What will happen if Google starts sending me messages at a rate faster than I can consume?

最后https://developers.google.com/cloud-messaging/ccs你可以阅读

Conversely, to avoid overloading the app server, CCS stops sending if there are too many unacknowledged messages. Therefore, the app server should "ACK" upstream messages, received from the client application via CCS, as soon as possible to maintain a constant flow of incoming messages. The aforementioned pending message limit doesn't apply to these ACKs. Even if the pending message count reaches 100, the app server should continue sending ACKs for messages received from CCS to avoid blocking delivery of new upstream messages.

在同一文档中,您找到了第二个和第三个问题的部分答案

If at any point the connection fails, you should immediately reconnect. There is no need to back off after a disconnect that happens after authentication.

对我来说,这意味着 Google 实现了一个简单的冗余逻辑并且可能不是一个公平的负载平衡系统(无论如何我希望如此)。如果您的交易量很大,我建议您直接与他们联系。

对于最后一个,ejabberd 是一个很好的产品,有很多已部署的系统具有集群基础架构,并且有大量关于如何做的文档。我建议你从这里开始 http://docs.ejabberd.im/admin/guide/clustering/ .

无论如何,对于您的高容量,我会评估 RabbitMQ,它是另一个 Erlang gem 。

关于android - 为上游 google gcm 构建 xmpp 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33231289/

相关文章:

android - 使用 xmpp 传输文件时出现错误代码 503

php - 使用 php 文件和 android 将数据添加到 postgreSql 数据库

java - 从 JSON 对象获取数组

android - 使用新的谷歌云消息传递的 Flash Air ANE 推送通知

ios - XEP 0055(Jabber 搜索)与 iphone SDK

browser - 浏览器之间的MIDI或OSC控件

Android Studio Compose Material3 模板主题

java - 捏合缩放如何与 Android 中的图像平移一起使用

android - 为什么 GCM 为某些 Android 设备返回空注册 ID?

ios - 无法获取用于在 iOS 中使用 GCM 实现推送通知的配置文件