Cosmos DB - 请求超时/服务当前不可用错误 [英] Cosmos DB - Request Time out / Service is currently unavailable Error

查看:140
本文介绍了Cosmos DB - 请求超时/服务当前不可用错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用cosmos DB并评估系统在负载下的执行情况。负载低至7-9K请求我们随机获取服务目前无法使用& 请求超时错误。


以下是代码


CREATE CLIENT 


  private void Initialize()

        {

            Client = new DocumentClient(new Uri(cosmosDbConfiguration.EndPoint),cosmosDbConfiguration.Key,new ConnectionPolicy

       {

          RetryOptions = new RetryOptions(){MaxRetryAttemptsOnThrottledRequests = 10,MaxRetryWaitTimeInSeconds = 180},



          ConnectionMode = ConnectionMode.Direct,

         ConnectionProtocol = Protocol.Tcp        

      });
$


  ;           Client.OpenAsync()。GetAwaiter();



            CreateDatabaseIfNotExistsAsync()。Wait();

            CreateAllCollectionsIfNotExistsAsync()。Wait();

        }


创建文档


  public async Task< Document> CreateDocumentAsync< T>(string collectionName,T dataRow)

  &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; return await Client.CreateDocumentAsync(GetCollectionUri(collectionName),dataRow);

  &NBSP; &NBSP; &NBSP; }



以下是错误消息以及活动ID 



服务目前无法使用。

ActivityId:6bfcabb0-69b9-4671-b2d1-8bf1a831d77e, 

RequestStartTime:2019 -04-08T21:48:14.3002274Z,尝试的区域数:1

ResponseTime:2019-04-08T21:48:48.3076636Z,StoreReadResult:StorePhysicalAddress:rntbd:// cdb-ms-prod -westus1-fd4.documents.azure.com:14070/apps/112e82de-8353-4f6c-804f-e6ce36a8282f/services/9f5b24ad-6517-4487-855b-ac5e507a6f53/partitions/e24c749b-c701-4b75-9a16-6dde04028f12/replicas / 131991744298606536p /,
LSN:-1,GlobalCommittedLsn:-1,PartitionKeyRangeId :, IsValid:False,StatusCode:410,IsGone:True,IsNotFound:False,IsInvalidPartition:False,RequestCharge:0,ItemLSN:-1, SessionToken:,ResourceType:Document,OperationType:Query

,documentdb-dotnet-sdk / 2.2.1 Host / 64-bit MicrosoftWindowsNT / 6.2.9200.0



消息:请求超时。

ActivityId:72f7f069-2376-4c71-af44-a78780e53894,请求URI:/ apps / 28ad6635-acc0-4a33-8cbf-513f2a7ecff0 / services / 9015ec89-5cc9 -4a36-825d-047766c72037 / partitions / bdc49db7-9018-4dd4-9100-52dcee4635a4 / replicas / 131992241935694598p /,RequestStats: 

RequestStartTime:2019-04-08T21:59:06.5769926Z,Number尝试的区域:1

,SDK:documentdb-dotnet-sdk / 2.2.1主机/ 64位MicrosoftWindowsNT / 6.2.9200.0







nirag.tibdewal@outlook.com


为同一讨论添加Stack Overflow链接:  Cosmos DB - 请求超时/服务当前不可用错误

解决方案

Hi Nirag,


感谢您提请我们注意。 


您能否检测一下获取一些响应信息的代码。这取自

为每个查询评估RU
。 

 //衡量效果(请求单位)写入
ResourceResponse< Document> response = await client.CreateDocumentAsync(collectionSelfLink,myDocument);

Console.WriteLine(" Insert of a items consume {0} request units",response.RequestCharge);

//衡量查询的性能(请求单位)
IDocumentQuery< dynamic> queryable = client.CreateDocumentQuery(collectionSelfLink,queryString).AsDocumentQuery();

while(queryable.HasMoreResults)
{
FeedResponse< dynamic> queryResponse = await queryable.ExecuteNextAsync< dynamic>();
Console.WriteLine(" Query batch consume {0} request units",queryResponse.RequestCharge);
}

可以找到有关直接模式与网关模式和.NET性能提示的一些其他信息:  < a href ="https://docs.microsoft.com/en-us/azure/cosmos-db/performance-tips\"target ="_ blank"> Azure Cosmos DB和.NET的性能提示 
在初始化期间添加一次OpenAsync方法以避免初始启动延迟: 

 await client.OpenAsync(); 

如果您仍有问题,请联系microsoft.com上的askcosmosdb并解释您是一个希望利用Cosmos DB的内部项目。如果您有其他问题,请告诉我们。



We using cosmos DB and evaluating how the system will perform under load. With load as low as 7-9K request we are randomly getting Service is currently unavailable & Request Time out Error.

Below is the code

CREATE CLIENT 

 private void Initialize()
        {
            Client = new DocumentClient(new Uri(cosmosDbConfiguration.EndPoint), cosmosDbConfiguration.Key, new ConnectionPolicy
            {
                RetryOptions = new RetryOptions() { MaxRetryAttemptsOnThrottledRequests = 10, MaxRetryWaitTimeInSeconds = 180 },

                ConnectionMode = ConnectionMode.Direct,
                ConnectionProtocol = Protocol.Tcp             
            });

            Client.OpenAsync().GetAwaiter();

            CreateDatabaseIfNotExistsAsync().Wait();
            CreateAllCollectionsIfNotExistsAsync().Wait();
        }

CREATE DOCUMENT

 public async Task<Document> CreateDocumentAsync<T>(string collectionName, T dataRow)
        {
            return await Client.CreateDocumentAsync(GetCollectionUri(collectionName), dataRow);
        }

Below are the error messages along with activity Id 

Service is currently unavailable.
ActivityId: 6bfcabb0-69b9-4671-b2d1-8bf1a831d77e, 
RequestStartTime: 2019-04-08T21:48:14.3002274Z, Number of regions attempted: 1
ResponseTime: 2019-04-08T21:48:48.3076636Z, StoreReadResult: StorePhysicalAddress: rntbd://cdb-ms-prod-westus1-fd4.documents.azure.com:14070/apps/112e82de-8353-4f6c-804f-e6ce36a8282f/services/9f5b24ad-6517-4487-855b-ac5e507a6f53/partitions/e24c749b-c701-4b75-9a16-6dde04028f12/replicas/131991744298606536p/, LSN: -1, GlobalCommittedLsn: -1, PartitionKeyRangeId: , IsValid: False, StatusCode: 410, IsGone: True, IsNotFound: False, IsInvalidPartition: False, RequestCharge: 0, ItemLSN: -1, SessionToken: , ResourceType: Document, OperationType: Query
, documentdb-dotnet-sdk/2.2.1 Host/64-bit MicrosoftWindowsNT/6.2.9200.0

Message: Request timed out.
ActivityId: 72f7f069-2376-4c71-af44-a78780e53894, Request URI: /apps/28ad6635-acc0-4a33-8cbf-513f2a7ecff0/services/9015ec89-5cc9-4a36-825d-047766c72037/partitions/bdc49db7-9018-4dd4-9100-52dcee4635a4/replicas/131992241935694598p/, RequestStats: 
RequestStartTime: 2019-04-08T21:59:06.5769926Z, Number of regions attempted: 1
, SDK: documentdb-dotnet-sdk/2.2.1 Host/64-bit MicrosoftWindowsNT/6.2.9200.0


nirag.tibdewal@outlook.com

Adding Stack Overflow link for same discussion: Cosmos DB - Request Time out / Service is currently unavailable Error

解决方案

Hi Nirag,

Thank you for bringing this to our attention. 

Can you instrument your code to get some response information. This is taken from the Evaluate RUs for every query

// Measure the performance (request units) of writes 
ResourceResponse<Document> response = await client.CreateDocumentAsync(collectionSelfLink, myDocument); 

Console.WriteLine("Insert of an item consumed {0} request units", response.RequestCharge); 

// Measure the performance (request units) of queries 
IDocumentQuery<dynamic> queryable = client.CreateDocumentQuery(collectionSelfLink, queryString).AsDocumentQuery(); 

while (queryable.HasMoreResults) 
     { 
          FeedResponse<dynamic> queryResponse = await queryable.ExecuteNextAsync<dynamic>(); 
          Console.WriteLine("Query batch consumed {0} request units", queryResponse.RequestCharge); 
     }

Some additional information with regard to direct mode versus gateway mode and .NET performance tips can be found: Performance tips for Azure Cosmos DB and .NET such as adding the OpenAsync method once during initialization to avoid initial start-up latency: 

await client.OpenAsync();

If you continue to have issues, please reach out to askcosmosdb at microsoft.com and explain you are an internal project looking to leverage Cosmos DB. Please let us know if you have additional questions.


这篇关于Cosmos DB - 请求超时/服务当前不可用错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆