诊断并排除 Cosmos DB 请求太多的故障Diagnose and troubleshoot Cosmos DB too many requests

“请求率太大”或错误代码 429 表明请求受到限制。'Request rate too large' or error code 429 indicates that your requests are being throttled.

疑难解答步骤Troubleshooting steps

下面的列表包含请求太多的已知原因和解决方案。The following list contains known causes and solutions for too many requests.

1.检查指标1. Check the Metrics

客户应检查 Azure Cosmos DB 监视,了解是否存在 429 异常。The customer should check the Azure Cosmos DB monitoring to check if the number 429 exceptions.

原因:Cause:

消耗的吞吐量 (RU/s) 超过预配吞吐量The consumed throughput (RU/s) has exceeded the provisioned throughput. SDK 会根据指定的重试策略自动重试请求。The SDK will automatically retry 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 are 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