我有一个相当大的(3000万行,每个高达5-100 on )表上的Azure。
每个RowKey都是Guid,PartitionKey是第一个Guid部分,例如:
PartitionKey = "1bbe3d4b"
RowKey = "1bbe3d4b-2230-4b4f-8f5f-fe5fe1d4d006"表每秒有600个读和600个写(更新),平均延迟为60 of 。所有查询都同时使用PartitionKey和RowKey。
但是,有些读取的高达3000 to (!)。平均而言,超过1%的读取占用500‘s以上,并且与实体大小无关(100 be行可以在25’s和10 be 1- in 1500‘s中返回)。
我的应用程序是一个运行在4-5个大型实例上的ASP.Net MVC 4网站。
我已经阅读了有关Azure表存储性能目标的所有MSDN文章,并已经完成了以下工作:
UseNagle被关闭Expect100Continue也被禁用MaxConnections设置为250个(设置1000-5000没有任何意义)我还查过:
造成这种性能问题的原因是什么,以及如何加以改进?
发布于 2015-09-01 20:12:34
如果我不打算在短期内更新实体,我将使用DataServiceContext.MergeOption属性上的DataServiceContext.MergeOption设置来获得额外的性能。下面是一个示例:
var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString"));
var tableStorageServiceContext = new AzureTableStorageServiceContext(account.TableEndpoint.ToString(), account.Credentials);
tableStorageServiceContext.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(1));
tableStorageServiceContext.MergeOption = MergeOption.NoTracking;
tableStorageServiceContext.AddObject(AzureTableStorageServiceContext.CloudLogEntityName, newItem);
tableStorageServiceContext.SaveChangesWithRetries();另一个问题可能是,尽管您只打算使用一两项属性,但您正在检索所有属性的整个敌意--这当然是浪费的,但很难避免。但是,如果使用斯拉夫人,则可以使用查询投影从表存储中检索您感兴趣的实体属性,仅此而已,这将为您提供更好的查询性能。下面是一个示例:
using SysSurge.Slazure;
using SysSurge.Slazure.Linq;
using SysSurge.Slazure.Linq.QueryParser;
namespace TableOperations
{
public class MemberInfo
{
public string GetRichMembers()
{
// Get a reference to the table storage
dynamic storage = new QueryableStorage<DynEntity>("UseDevelopmentStorage=true");
// Build table query and make sure it only return members that earn more than $60k/yr
// by using a "Where" query filter, and make sure that only the "Name" and
// "Salary" entity properties are retrieved from the table storage to make the
// query quicker.
QueryableTable<DynEntity> membersTable = storage.WebsiteMembers;
var memberQuery = membersTable.Where("Salary > 60000").Select("new(Name, Salary)");
var result = "";
// Cast the query result to a dynamic so that we can get access its dynamic properties
foreach (dynamic member in memberQuery)
{
// Show some information about the member
result += "LINQ query result: Name=" + member.Name + ", Salary=" + member.Salary + "<br>";
}
return result;
}
}
}完全揭露:我编码斯拉夫。
如果要检索大型数据集,还可以考虑分页,例如:
// Retrieve 50 members but also skip the first 50 members
var memberQuery = membersTable.Where("Salary > 60000").Take(50).Skip(50);发布于 2015-08-21 16:18:10
通常,如果特定的查询需要扫描大量行,则这将花费更长的时间。您所看到的行为是否是特定的查询/数据?或者,对于相同的数据和查询,您是否看到性能不同?
https://stackoverflow.com/questions/32077723
复制相似问题