Firebase 在大型数据集上的性能 [英] Performance of Firebase with large data sets
问题描述
我正在为一个可能有相当多的密钥(可能有数百万个)的项目测试 Firebase.
I'm testing firebase for a project that may have a reasonably large numbers of keys, potentially millions.
我测试过用node加载了几万条记录,加载性能看起来不错.然而,如果我展开我的根节点,FORGE"Web UI 会变得非常缓慢并且呈现每条记录.
I've tested loading a few 10k of records using node, and the load performance appears good. However the "FORGE" Web UI becomes unusably slow and renders every single record if I expand my root node.
Firebase 是否不是为这种数据量而设计的,还是我做错了什么?
Is Firebase not designed for this volume of data, or am I doing something wrong?
推荐答案
这只是 Forge UI 的局限性.它仍然相当初级.
It's simply the limitations of the Forge UI. It's still fairly rudimentary.
Firebase 中的实时函数不仅适用于,而且专为大型数据集而设计.实时记录流这一事实非常适合这一点.
The real-time functions in Firebase are not only suited for, but designed for large data sets. The fact that records stream in real-time is perfect for this.
与任何大数据应用一样,性能取决于您的实施.因此,这里有一些大数据集需要注意的问题.
Performance is, as with any large data app, only as good as your implementation. So here are a few gotchas to keep in mind with large data sets.
去正规化、去正规化、去正规化
如果一个数据集会被迭代,并且它的记录可以数以千计,则将其存储在自己的路径中.
If a data set will be iterated, and its records can be counted in thousands, store it in its own path.
这不利于迭代大型数据集:
This is bad for iterating large data sets:
/users/uid
/users/uid/profile
/users/uid/chat_messages
/users/uid/groups
/users/uid/audit_record
这有利于迭代大型数据集:
This is good for iterating large data sets:
/user_profiles/uid
/user_chat_messages/uid
/user_groups/uid
/user_audit_records/uid
避免在大型数据集上使用价值"
使用child_ added
,因为value
必须将整个记录集加载到客户端.
Use the child_added
since value
must load the entire record set to the client.
注意子项上隐藏的value
操作
Watch for hidden value
operations on children
当您调用 child_ added
时,您实际上是在每个子记录上调用 value
.因此,如果这些孩子包含大列表,他们将不得不加载所有数据以返回.因此,上面的 DENORMALIZE 部分.
When you call child_added
, you are essentially calling value
on every child record. So if those children contain large lists, they are going to have to load all that data to return. Thus, the DENORMALIZE section above.
这篇关于Firebase 在大型数据集上的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!