firebase - 通过添加区域来扩展 firebase 的推荐方法

标签 firebase firebase-realtime-database google-cloud-firestore google-cloud-functions

目前我有 3 个用于应用程序的 Firebase 项目:live、beta、development

这些处理各自的环境并且都在美国区域内。

future ,如果应用程序在全局范围内使用,在欧盟/亚洲+美国扩展的推荐方式是什么?我最初的本能是创建额外的 firebase 项目,例如 live-eu、live-asia,但我在这里看到一个问题:

这些项目可以使用与我的美国项目当前使用的应用程序 ID 相同的应用程序 ID 吗?我无法从美国项目导入数据,因为它有 uid's在那里,这些肯定不能与其他项目的授权一起使用吗?但我需要允许用户转换到其他区域。

我无法在一个地方收集所有区域的分析数据,对吗?

因此问题是,有没有办法在 Firebase 项目中扩展/添加多区域支持?对 Firestore 和云功能特别感兴趣,因为这些功能可以减少延迟。

最佳答案

我在评论中询问但没有得到回复,所以我假设您的应用程序具有读取密集型工作负载。对于这些情况,为了减少来自世界各地的请求的延迟,您应该使用 CDN 来缓存静态文件和响应(即利用边缘位置和边缘计算)。您甚至不需要坚持使用 Firebase(Akamai 和 CloudFront 等解决方案可能满足您的需求并轻松插入您的 Firebase 解决方案),但如果您需要,请查看 Firebase Hosting .

如果您的工作负载是写入密集型的,请尝试使用异步机制(例如消息队列)来保证向用户提供更快的反馈。通常,写入操作不需要立即/同步执行,但同样,最好了解您的工作负载以给出更准确的答案。

编辑:Google 最近宣布 Firestore -- 他们提供多区域支持以提高可用性:

A multi-region location is a general geographical area, such as the United States. Data in a multi-region location is replicated in multiple regions. Within a region, data is replicated across zones.

在可扩展性方面,这是他们在 their blog 中给出的说法:

Cloud Firestore [...] is built on top of the same Google Cloud infrastructure that powers some pretty popular apps. So it will be able to scale much more easily and to a much greater capacity than the Realtime Database can.

And with the new querying structure, all Cloud Firestore queries scale to the size of your result set -- not the size of your data. This means that a search for the top 10 restaurants in Chicago for a restaurant review app will take the same amount of time whether your database has 300 restaurants, 300 thousand or 30 million. As one engineer here likes to put it, "It's basically impossible to create a slow query in Cloud Firestore."

请注意,Firestore 中的写入具有强一致性(这意味着与最终一致性解决方案相比,它们具有更高的延迟)。

关于firebase - 通过添加区域来扩展 firebase 的推荐方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51960435/

相关文章:

javascript - 如何从firebase列表中删除项目

arrays - 如何获取Firebase快照的长度?

angular - 使用 Angular 火灾设置 Firestore 会导致 : NullInjectorError: R3InjectorError(HomePageModule)

javascript - 对象作为 Firestore 中的查询参数

ios - Swift 中的 ImageView 到 Firebase 存储

php - 通过 FCM google-php-api HTTPv1 API 发送推送消息

android - 下载时出现 Firebase StorageException

android - 动态卡片 View 与 Firebase 相结合

angular - 路由超时。 Angular 9 通用 + Firebase

javascript - Firebase 多路径更新 "invalid data; couldn' t 解析 JSON 对象、数组或值”