现已推出具有 MongoDB 兼容性的 Firestore 企业版!
了解详情。
解决延迟问题
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
仅与 Cloud Firestore 企业版相关。
|
本页面介绍了如何解决与 MongoDB 兼容的 Cloud Firestore 的延迟问题。
延迟时间
下表介绍了可能导致延迟时间增加的原因:
延迟原因 |
受影响的操作类型 |
解决方法 |
流量持续增加。
|
读取、写入 |
对于流量快速增加,与 MongoDB 兼容的 Cloud Firestore 会尝试自动扩缩以满足增加的需求。与 MongoDB 兼容的 Cloud Firestore 扩缩时,延迟时间会开始缩短。
热点(窄文档范围的高读取、写入和删除速率)限制了与 MongoDB 兼容的 Cloud Firestore 扩缩的能力。查看避免热点,并确定应用中的热点。
|
由于更新单个文档过于频繁或由于事务导致争用。 |
读取、写入 |
降低各个文档的写入速率。
减少单次写入事务中更新的文档数量。
|
返回许多文档的大批量读取操作。 |
read |
使用分页拆分大量读取操作。 |
最近的删除操作过多。 |
读取 这大大影响了列出数据库中集合的操作。 |
如果延迟是由最近的删除操作过多导致的,则问题应会在一段时间后自动解决。如果问题未解决,请与支持团队联系。 |
索引扇出,特别是对于数组字段和嵌入文档字段。 |
write |
查看数组字段和嵌入文档字段的索引编入情况。 |
大量写入操作。 |
write |
尝试减少每次操作的写入次数。
对于不需要原子性的批量数据条目,请使用并行执行各项写入操作。
|
如未另行说明,那么本页面中的内容已根据知识共享署名 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\nThis page shows you how to resolve latency issues with Cloud Firestore with MongoDB compatibility.\n\nLatency\n\nThe following table describes possible causes of increased latency:\n\n| Latency cause | Types of operations affected | Resolution |\n|-----------------------------------------------------------------------------------------|---------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Sustained, increasing traffic. | read, write | For rapid traffic increases, Cloud Firestore with MongoDB compatibility attempts to automatically scale to meet the increased demand. When Cloud Firestore with MongoDB compatibility scales, latency begins to decrease. Hot-spots (high read, write, and delete rates to a narrow document range) limit the ability of Cloud Firestore with MongoDB compatibility to scale. Review [Avoid hot-spots](https://cloud.google.com/firestore/mongodb-compatibility/docs/understand-reads-writes-scale#avoid_hotspots) and identify hot-spots in your application. |\n| Contention, either from updating a single document too frequently or from transactions. | read, write | Reduce the write rate to individual documents. Reduce the number of documents updated in a single write transaction. |\n| Large reads that return many documents. | read | Use pagination to split large reads. |\n| Too many recent deletes. | read This greatly affects operations that list collections in a database. | If latency is caused by too many recent deletes, the issue should automatically resolve after some time. If the issue does not resolve, [contact support](https://firebase.google.com/support). |\n| Index fanout, especially for array fields and embedded document fields. | write | Review your indexing of array fields and embedded document fields. |\n| Large writes. | write | Try reducing the number of writes in each operation. For bulk data entry where you don't require atomicity, use parallelized individual writes. |"]]