Firestore中的onSnapshot的性能成本是多少? [英] What is the performance cost of an onSnapshot in firestore?

查看:53
本文介绍了Firestore中的onSnapshot的性能成本是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个包含(许多)文档的应用程序,这些文档可以共享给(可能很多)组.

I am designing an app that contains (a lot of) documents which are shared to (possibly many) groups.

我需要了解如何将文档更改从服务器推送到客户端以建立数据模型.

I need to understand how document changes are pushed from the server to the client in order to build my data model.

  1. 是否已将对数据库的所有更改推送到客户端(数据最少),客户端是否下载了已在 onSnapshot 中注册的内容?
  2. 远程服务器上是否有一个已更新且仅将相关数据推送到客户端的过滤器?

在模型(1)中,添加许多 onSnapshot (每个文档一个)的成本似乎较低.在模型(2)中,它可能很高,但对服务器却是一个负担?所有这些都与Firestore定价模型(读取计数)有何关系.

In model (1), the cost of adding many onSnapshot (one for every document) seems low. In model (2), it could be high but it is a burden on the server ? How does all this relate to firestore pricing model (Read counts).

谢谢你在这里开灯...

Thanks for any lights on this...

推荐答案

实际上,答案在当我们创建 onSnapshot 时,查询将发送到服务器,该服务器会记住客户端感兴趣的内容并更新其通知过滤器.

When we create an onSnapshot, the query is sent to the server which remembers what the client is interested in and updates it's notification filter.

这意味着我们处于方案#2中,它说明了服务器打开连接的成本.

This means that we are in scenario #2 and it explains the cost of open connections for the server.

这也意味着我们不在乎我们创建了多少 onSnapshot .关于客户端,对我们获得的每个文档执行一个 onSnapshot 并没有性能问题(但是存在

This also means that we do not care how many onSnapshot we create. Concerning the client, there is no performance issue in doing one onSnapshot for each document we get (but there is a Read cost in Firestore for this).

这篇关于Firestore中的onSnapshot的性能成本是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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