簡體   English   中英

Microsoft.Azure.Cosmos.Table 和 Microsoft.WindowsAzure.Storage 之間的 ExecuteQuerySegmentedAsync 性能顯着下降

[英]Significant performance degration on ExecuteQuerySegmentedAsync between Microsoft.Azure.Cosmos.Table and Microsoft.WindowsAzure.Storage

我一直在研究從存儲帳戶表存儲遷移到 CosmosDB 表存儲。 目前我正在使用 WindowsAzure.Storage (9.3.3) 庫來查詢 .net 核心 3.1 應用程序中的數據。 作為此遷移的一部分,我已切換到 Microsoft.Azure.Cosmos.Table 1.0.7 庫。 我在下面編寫了 LinqPad 基准測試來比較兩者在進行全表掃描時的性能。

async Task Main()
{
    var timer = Stopwatch.StartNew();
    await QueryCosmosDb().ConfigureAwait(false);
    timer.Stop();
    var cosmosExecutionTime = timer.Elapsed;

    timer = Stopwatch.StartNew();
    await QueryTableStorage().ConfigureAwait(false);
    timer.Stop();
    var tableExecutionTime = timer.Elapsed;
    
    cosmosExecutionTime.Dump();
    tableExecutionTime.Dump();
}

public async Task QueryCosmosDb()
{
    var cosmosTableEndpoint = new Uri($"https://***.table.cosmos.azure.com:443/");
    var storageAccount = new Microsoft.Azure.Cosmos.Table.CloudStorageAccount(new Microsoft.Azure.Cosmos.Table.StorageCredentials("***", "****"), cosmosTableEndpoint);
    var client = storageAccount.CreateCloudTableClient();
    var table = client.GetTableReference("tablename");
    var query = new Microsoft.Azure.Cosmos.Table.TableQuery();
    Microsoft.Azure.Cosmos.Table.TableContinuationToken token = null;
    do
    {
        var segment = await table.ExecuteQuerySegmentedAsync(query, token).ConfigureAwait(false);
        token = segment.ContinuationToken.Dump();
    }
    while (token != null);
}

public async Task QueryTableStorage()
{
    var storageAccount = new Microsoft.WindowsAzure.Storage.CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials("***", "****"), true);
    var client = storageAccount.CreateCloudTableClient();
    var table = client.GetTableReference("tablename");
    var query = new Microsoft.WindowsAzure.Storage.Table.TableQuery();
    Microsoft.WindowsAzure.Storage.Table.TableContinuationToken token = null;
    do
    {
        var segment = await table.ExecuteQuerySegmentedAsync(query, token).ConfigureAwait(false);
        token = segment.ContinuationToken;
    }
    while (token != null);
}

存儲帳戶表和 CosmosDb 表具有大約 200k 個實體的相同數據集。

Cosmos 表帳戶的共享供應吞吐量為 2200 RU。

將 Cosmos Executor 與 Microsoft.Azure.Cosmos.Table 庫一起使用時,執行時間約為 3 小時。 帶有 Microsoft.WindowsAzure.Storage 庫的存儲帳戶表大約需要 2 分鍾。 如果我在 Cloud Table 客戶端中切換 Microsoft.Azure.Cosmos.Table 庫以使用 rest 執行器,我會得到約 3 分鍾的執行時間。

有沒有人遇到過類似的行為或意識到空表查詢的問題?

還添加了azure-cosmos-table-dotnet中 Github 問題的票證

它是導致時差的 ExecuteQuery 方法的內部實現,因此除非 Microsoft 注意到並在即將發布的版本中修復了該問題,否則我們沒有機會解決該問題,無論如何,現在他們已棄用並使用通用庫Microsoft.Azure.Cosmos它一定已經解決了這個問題,希望這有幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM