azure - 升级到 Microsoft.Azure.Cosmos.Table 访问 Azure 表存储后性能下降

标签 azure azure-table-storage azure-sdk-.net

我们升级到了下一版本的 SDK 以访问我们的 Azure 表存储。

此后我们观察到应用程序的性能下降。我们甚至创建了具有相同使用模式的测试应用程序来隔离它,但仍然看到了这种性能影响。

我们正在使用 .NET Framework 代码,从 Azure 表读取数据。

旧客户端:Microsoft.WindowsAzure.Storage - 9.3.2

新客户端:Microsoft.Azure.Cosmos.Table - 1.0.6

这是我们尝试运行的示例测试之一:

public async Task ComparisionTest1()
{
    var partitionKey = CompanyId.ToString();

    {
        // Microsoft.Azure.Cosmos.Table
        var storageAccount = Microsoft.Azure.Cosmos.Table.CloudStorageAccount.Parse(ConnectionString);
        var tableClient = Microsoft.Azure.Cosmos.Table.CloudStorageAccountExtensions.CreateCloudTableClient(storageAccount);
        var tableRef = tableClient.GetTableReference("UserStatuses");
        var query = new Microsoft.Azure.Cosmos.Table.TableQuery<Microsoft.Azure.Cosmos.Table.TableEntity>()
                            .Where(Microsoft.Azure.Cosmos.Table.TableQuery.GenerateFilterCondition("PartitionKey", "eq", partitionKey));
        var result = new List<Microsoft.Azure.Cosmos.Table.TableEntity>(20000);

        var stopwatch = Stopwatch.StartNew();
        var tableQuerySegment = await tableRef.ExecuteQuerySegmentedAsync(query, null);
        result.AddRange(tableQuerySegment.Results);
        while (tableQuerySegment.ContinuationToken != null)
        {
            tableQuerySegment = await tableRef.ExecuteQuerySegmentedAsync(query, tableQuerySegment.ContinuationToken);
            result.AddRange(tableQuerySegment.Results);
        }

        stopwatch.Stop();
        Trace.WriteLine($"Cosmos table client. Elapsed: {stopwatch.Elapsed}");
    }

    {
        // Microsoft.WindowsAzure.Storage
        var storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(ConnectionString);
        var tableClient = storageAccount.CreateCloudTableClient();
        var tableRef = tableClient.GetTableReference("UserStatuses");
        var query = new Microsoft.WindowsAzure.Storage.Table.TableQuery<Microsoft.WindowsAzure.Storage.Table.TableEntity>()
                            .Where(Microsoft.WindowsAzure.Storage.Table.TableQuery.GenerateFilterCondition("PartitionKey", "eq", partitionKey));
        var result = new List<Microsoft.WindowsAzure.Storage.Table.TableEntity>(20000);

        var stopwatch = Stopwatch.StartNew();
        var tableQuerySegment = await tableRef.ExecuteQuerySegmentedAsync(query, null);
        result.AddRange(tableQuerySegment.Results);
        while (tableQuerySegment.ContinuationToken != null)
        {
            tableQuerySegment = await tableRef.ExecuteQuerySegmentedAsync(query, tableQuerySegment.ContinuationToken);
            result.AddRange(tableQuerySegment.Results);
        }

        stopwatch.Stop();
        Trace.WriteLine($"Old table client. Elapsed: {stopwatch.Elapsed}");
    }
}

有人观察过它,对此有什么想法吗?

最佳答案

经大型实体验证,性能问题将在 Table SDK 1.0.7 中得到解决。 在 1.0.6 上,解决方法是通过在 app.config 中添加诊断部分来禁用 Table sdk 跟踪(如果它是 .NET Framework 应用程序)。它仍然比 Storage sdk 慢,但比没有解决方法要好得多,具体取决于使用情况。

关于azure - 升级到 Microsoft.Azure.Cosmos.Table 访问 Azure 表存储后性能下降,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61084190/

相关文章:

c# - 使用 TableServiceEntity 将复杂对象插入到 azure 表中

azure - 与 Get-AzureRmSqlServerThreatDetectionPolicy 等效的 C# 是什么?

asp.net - 将现有的 asp.net 应用程序连接到 azure sql server vm,无需 SDK

azure - Application Insight (Azure) 中的计时事件

c# - 如何检查Azure函数是否在本地环境中运行? `RoleEnvironment` 无法在 Azure Functions 中运行

azure - 如何将数据从azure数据湖移动到Windows虚拟机

javascript - 如何将毫秒转换为 Javascript UTC 日期?

Azure表存储: Order by

Azure 队列查看所有消息

azure 应用程序洞察: troubleshoot size messages