asp.net-mvc – 如何减少Azure表存储延迟?
| 
                         
 我有一个相当庞大的(30毫升行,每个最多5-100Kb)表在Azure上. 
  
每个RowKey都是一个Guid,而PartitionKey是第一个Guid部分,例如: PartitionKey = "1bbe3d4b" RowKey = "1bbe3d4b-2230-4b4f-8f5f-fe5fe1d4d006" 表每秒有600次读取和600次写入(更新),平均延迟为60ms.所有查询都使用PartitionKey和RowKey. 我的应用程序是在4-5个大型实例上运行的ASP.Net MVC 4网站. 我已阅读有关Azure表存储性能目标的所有MSDN文章,并已执行以下操作: > UseNagle已关闭 我也检查过: >存储帐户监控计数器没有限制错误 这种性能问题可能是什么原因以及如何改进? 解决方法
 如果我不打算很快更新实体,我会使用 
 DataServiceContext.MergeOption属性上的 
 MergeOption.NoTracking设置获得额外的性能.这是一个例子: 
  
  
  
        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(); 
 另一个问题可能是你正在检索整个enity及其所有属性,即使你只想使用一个或两个属性 – 这当然是浪费但不能轻易避免.但是,如果您使用Slazure,那么您可以使用查询投影仅从表存储中检索您感兴趣的实体属性,仅此而已,这将为您提供更好的查询性能.这是一个例子: 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;
        }
    }
} 
 完全披露:我编码了Slazure. 如果要检索大型数据集,也可以考虑分页,例如: // Retrieve 50 members but also skip the first 50 members
var memberQuery = membersTable.Where("Salary > 60000").Take(50).Skip(50);
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!  | 
                  
- asp.net-mvc – 使用类似MvcContrib Grid的东西在代码可读性
 - 在ASP.NET Core中相关的ConfigureAwait(false)?
 - asp.net-mvc – MVC中的绑定集合
 - ASP.NET 根据汉字获取汉字拼音的首字母(含多音字)
 - asp.net-mvc-3 – HTML.DropdownList – 文本字段显示多列的
 - asp.net-mvc – 启用SSL时,IIS默认为HTTPS的端口44300
 - asp.net-core – ASP.NET 5中的HandleUnknownAction
 - [译]ASP.NET Core 2.0 网址重定向的方法
 - asp.net-mvc – ASP MVC – 有默认内容类型的任何常量?
 - 给 asp.net core 写个中间件来记录接口耗时
 
- asp.net-mvc – 用户个人头像asp.net mvc identi
 - asp.net-mvc – Asp.net Mvc自定义机制来处理未经
 - asp.net-mvc – 更改项目URL Visual Studio
 - asp.net-core – ASP.NET Core 1.1中的multipart
 - asp.net-mvc-5 – 当我点击外部提供商按钮时,为什
 - asp.net-mvc – 添加视图模型类下拉列表不显示我
 - asp.net-mvc – 帖子上的Mvc模型ID 0
 - asp.net-mvc-3 – 如何在VIEW MVC3 Razor中显示w
 - asp.net – 缓存SELECT语句的结果,以便在多个查询
 - asp.net-mvc – SSL安全SaaS应用程序的URL设计
 
