诊断 Azure Cosmos DB 请求速率过大异常并对其进行故障排除Diagnose and troubleshoot Azure Cosmos DB request rate too large exceptions

适用于: SQL API

“请求速率过大”消息或错误代码 429 表明请求受到限制。A "Request rate too large" message or error code 429 indicates that your requests are being throttled.

疑难解答步骤Troubleshooting steps

以下部分包含请求过多的已知原因和解决方案。The following section contains known causes and solutions for too many requests.

检查指标Check the metrics

检查 Azure Cosmos DB 监视,查看 429 异常的数量。Check Azure Cosmos DB monitoring to see the number of 429 exceptions.

原因:Cause:

消耗的吞吐量(请求单位/秒)已超过预配的吞吐量The consumed throughput (Request Units per second) has exceeded the provisioned throughput. SDK 会根据指定的重试策略自动重试请求。The SDK automatically retries requests based on the specified retry policy. 如果经常遇到这种失败,请考虑增大集合的吞吐量。If you get this failure often, consider increasing the throughput on the collection. 检查门户的指标,确定是否收到了 429 错误。Check the portal's metrics to see if you're getting 429 errors. 查看分区键,以确保均匀分配存储和请求量Review your partition key to ensure it results in an even distribution of storage and request volume.

解决方案:Solution:

  1. 使用门户或 SDK 增加预配的吞吐量。Use the portal or the SDK to increase the provisioned throughput.
  2. 将数据库或容器切换为自动缩放Switch the database or container to Autoscale.

后续步骤Next steps