Posted on

Original article NET and ADO.NET Data Service Performance Tips for Windows Azure Tables.

 

Summary:

Default .NET HTTP connections is set to 2

Config file:  
  <system.net> 
    <connectionManagement> 
      <add address = "*" maxconnection = "48" /> 
    </connectionManagement> 
  </system.net> 

In code:  
ServicePointManager.DefaultConnectionLimit = 48; 

Turn off 100-continue (saves 1 roundtrip)

    Code:  
    ServicePointManager.Expect100Continue = false; // or on service point if only a particular service needs to be disabled.  
     
    Config file:  
    <system.net> 
    
        <settings> 
    
          <servicePointManager expect100Continue="false" /> 
    
        </settings> 
     
    </system.net> 

To improve performance of ADO.NET Data Service deserialization name CLR Enity and table identically and use ResolveType on the

public void Query(DataServiceContext context) 
                {  
                     // set the ResolveType to a method that will return the appropriate type to creat

                     context.ResolveType = this.ResolveEntityType;   

                }  
 public Type ResolveEntityType(string name) 
 {  

                      // if the context handles just one type, you can return it without checking the   
                      // value of "name".  Otherwise, check for the name and return the appropriate  
                      // type (maybe a map of Dictionary<string, Type> will be useful) 

                      Type type  = typeof(Customer);
                      return type;  
}  

Turn entity tracking off for query results that are not going to be modified.

    context.MergeOption = MergeOption.NoTracking;

    Use unconditional updates/deletes

    context.AttachTo("TableName", entity, "*");   
    context.UpdateObject(entity); 

 Turning off Nagle may help Inserts/Updates

Code:   
ServicePointManager.UseNagleAlgorithm = false; 

Config file: 

<system.net> 
    <settings> 
      <servicePointManager expect100Continue="false" useNagleAlgorithm="false"/> 
    </settings> 
</system.net>