简体   繁体   中英

How to avoid startup latency for Azure Table Storage/Cosmos DB Table API on .Net Core

Microsoft documentation here suggests to use await client.OpenAsync(); to avoid startup latency to Cosmos DB. This seems to be only applicable to SQL API. I try to use Table API and could not manage to do the same. My first request executes in 1500 ms and subsequent takes only 40, so that would be a very nice improvement.

I had tried both Microsoft.Azure.Cosmos.Table and Microsoft.WindowsAzure.Storage to connect, but did not find any way of doing that. The only thing I can think of is doing a "dummy" request that for sure does not return anything instead to achieve the same goal.

Is there any better way to initialize the connection?

A simple solution would be to query anything that you know exists.

Any call using the client will initialise the connection and do the (approximately) 8 requests that CosmosDB needs.

Reading the database account would be the simplest way to achieve this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM