title: Cosmos DB - Request Time out / Service is currently unavailable Error
body: <p>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 &amp; Request Time out Error.</p>
  
  <p>Has anyone else faced this issue?</p>
  
  <p>Below is the code</p>
  
  <p><strong>CREATE CLIENT</strong> </p>
  
  <pre><code>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();
      }
  </code></pre>
  
  <p><strong>CREATE DOCUMENT</strong></p>
  
  <pre><code> public async Task&lt;Document&gt; CreateDocumentAsync&lt;T&gt;(string collectionName, T dataRow)
      {
          return await Client.CreateDocumentAsync(GetCollectionUri(collectionName), dataRow);
      }
  </code></pre>
  
  <p>Below are the error messages along with activity Id </p>
  
  <blockquote>
    <p>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</p>
    
    <p>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</p>
  </blockquote>