升级到 Microsoft.Azure.Cosmos.Table 以访问 Azure table 存储后性能下降
Performance degradation after upgrading to Microsoft.Azure.Cosmos.Table to access Azure table storage
我们升级到下一版本的 SDK 以访问我们的 Azure Table 存储。
之后我们观察到应用程序的性能下降。我们甚至创建了具有相同使用模式的测试应用程序来隔离它,并且仍然看到这种性能下降。
我们正在使用 .NET Framework 代码,从 Azure table 读取数据。
老客户: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。以防万一,如果这是 CosmosDB Table 支持,将 TableClientConfiguration.UseRestExecutorForCosmosEndpoint 设置为 True 可能会获得更好的性能。
如果是旧版 Storage Table 存储,CosmosDB Table sdk 1.0.6 比 Storage Table sdk 9.3.3 慢大约 15%。此外,它在第一次 CRUD 操作时还有额外的第二次开销。更高的查询持续时间已在 1.0.7 中得到解决,这与 Storage SDK 相当。为什么使用CosmosDB Table sdk 1.0.7 还是需要初始化秒,应该可以接受。
我们计划在 4 月 13 日那一周发布 1.0.7。
经大型实体验证,性能问题将在 Table SDK 1.0.7 中得到解决。
在 1.0.6 上,解决方法是通过在 app.config 中添加诊断部分来禁用 Table sdk 跟踪(如果它是 .NET 框架应用程序)。它仍然会比 Storage sdk 慢,但比没有解决方法要好得多,具体取决于使用情况。
我们升级到下一版本的 SDK 以访问我们的 Azure Table 存储。
之后我们观察到应用程序的性能下降。我们甚至创建了具有相同使用模式的测试应用程序来隔离它,并且仍然看到这种性能下降。
我们正在使用 .NET Framework 代码,从 Azure table 读取数据。
老客户: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。以防万一,如果这是 CosmosDB Table 支持,将 TableClientConfiguration.UseRestExecutorForCosmosEndpoint 设置为 True 可能会获得更好的性能。
如果是旧版 Storage Table 存储,CosmosDB Table sdk 1.0.6 比 Storage Table sdk 9.3.3 慢大约 15%。此外,它在第一次 CRUD 操作时还有额外的第二次开销。更高的查询持续时间已在 1.0.7 中得到解决,这与 Storage SDK 相当。为什么使用CosmosDB Table sdk 1.0.7 还是需要初始化秒,应该可以接受。
我们计划在 4 月 13 日那一周发布 1.0.7。
经大型实体验证,性能问题将在 Table SDK 1.0.7 中得到解决。 在 1.0.6 上,解决方法是通过在 app.config 中添加诊断部分来禁用 Table sdk 跟踪(如果它是 .NET 框架应用程序)。它仍然会比 Storage sdk 慢,但比没有解决方法要好得多,具体取决于使用情况。