现已推出具有 MongoDB 兼容性的 Firestore 企业版!
了解详情。
理解大规模读写操作
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
仅与 Cloud Firestore 企业版相关。
|
阅读本文档,学习如何做出关于应用架构设计的明智决策,以使其具有高性能和可靠性。本文档包含高级 Cloud Firestore 主题。如果您刚刚开始使用 Cloud Firestore,请改为参阅快速入门指南。为了确保在数据库大小和流量增加时应用仍能正常运行,了解 Firestore 后端中的读写机制很有帮助。您还必须了解读写操作与存储层之间的交互,以及可能影响性能的底层限制。
如需了解在设计应用架构之前应遵循的一些最佳实践,请参阅以下内容:
- 了解 API 请求的高级层组件。
- 所有写入操作都作为读写事务处理,以确保 ACID 属性。如果写入涉及多个分块,则可能需要两阶段提交流程。
- 默认情况下,读取具有“强一致性”,并使用基于时间戳的方法来避免锁定。
- 为保持高性能,您应通过在整个键范围内分布操作并保持事务较小来避免热点。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[],[],null,["\u003cbr /\u003e\n\n\n|--------------------------------------------------------|\n| *Relevant to Cloud Firestore Enterprise edition only.* |\n\n\u003cbr /\u003e\n\nRead this document to make informed decisions on architecting your applications\nfor high performance and reliability. This document includes advanced\nCloud Firestore topics. If you're just starting out with Cloud Firestore,\nsee the [quickstart guide](/docs/firestore/enterprise/create-and-query-database)\ninstead. To make sure that your applications continue to perform well as your\ndatabase size and traffic increase, it helps to understand the mechanics of\nreads and writes in the Firestore backend. You must also understand the\ninteraction of your read and writes with the storage layer and the underlying\nconstraints that may affect performance.\n\nTo learn about some best practices before architecting your application, read\nthe following:\n\n- Understand the [high level components](https://cloud.google.com/firestore/mongodb-compatibility/docs/understand-reads-writes-scale#understand_the_high_level_components) of an API request.\n- All [writes](https://cloud.google.com/firestore/mongodb-compatibility/docs/understand-reads-writes-scale#understand_the_life_of_a_write) are handled as read-write transactions to ensure ACID properties. If a write involves multiple splits, it may require a two-phase commit process.\n- [Reads](https://cloud.google.com/firestore/mongodb-compatibility/docs/understand-reads-writes-scale#understand_the_life_of_a_read), by default, are \"strongly consistent\" and use a timestamp-based approach to avoid locks.\n- To maintain high performance, you should [avoid hotspots](https://cloud.google.com/firestore/mongodb-compatibility/docs/understand-reads-writes-scale#avoid_hotspots) by distributing operations across the key range and keeping transactions small."]]